1

我遇到的问题是,当我单击网站上具有相对 URL 的链接或按钮时,我收到 404 错误,因为它将链接设置为根

前任

我的路由器设置如下:

define([
'jquery',
'underscore',
'backbone',
'views/home/main',
'views/projects/list',
'views/users/list'
], function($, _, Backbone, mainHomeView, projectListView, userListView ){

var AppRouter = Backbone.Router.extend({
   routes: {
       'projects': 'showProjects',
       'users': 'showUsers',
       '*actions': 'defaultAction'
    },
  initialize: function(){
        this.home = new mainHomeView.homeView(this);
        this.user = new userListView.userView(this);
        this.project = new projectListView.projectView(this);
  },
  showProjects: function(){
        this.project.render();
  },

    showUsers: function(){
        this.user.render();
    },
    defaultAction: function(actions){
        this.home.render()
    }
});

var initialize = function(){
        var app_router = new AppRouter;
        Backbone.history.start();
};

return {
    initialize: initialize
};
});

我的按钮/链接设置如下:

 <ul>
      <li><a href="#/links">Links</a></li>
 </ul>

所以如果我的网址是:www.some-web-site.com/example/ex1/

我点击它应该将网址设置为的链接:www.some-web-site.com/example/ex1/#/links

相反,我得到:404 not found - www.some-web-site.com/links

我错过了什么吗?谢谢

4

0 回答 0