Sammy.js 404在根路径上 [英] Sammy.js 404 on root path

查看:66
本文介绍了Sammy.js 404在根路径上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用sammy.js定义一些路线,这里是我的代码:

I'm trying to define some routes with sammy.js here is my code:

$.sammy("#main_content", function()
{
    this.get("#!/about", function()
    {
        // Code
    });

    this.get("#!/", function()
    {
        // Code
    });
}).run();

如果我转到www.mywebsite.com我总是收到404错误。我已尝试在 this.get(,function(){}); 中设置空白路径,这似乎可以防止404错误,但之后没有我在网页上的正常链接工作。我该如何解决此问题?

If I goto www.mywebsite.com I always get a 404 error. I've tried putting a blank route in like this.get("", function() {}); and that seems to work for preventing the 404 error but then none of my normal links on the page work. How do I go about fixing this?

推荐答案

只是覆盖未找到:

this.notFound = function(){
//做点什么
}

this.notFound = function(){ // do something }

你可以在这里看到: https://github.com/quirkey/sammy/issues/67

这篇关于Sammy.js 404在根路径上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆