Backbone route with push state not working on page refresh

左心房为你撑大大i 提交于 2019-12-02 21:01:25

问题


var Backbone = require('backbone'),
SellerProfileView = require('./views/seller/SellerProfileView');

var Router = Backbone.Router.extend({
    routes: {
        ":user_name" : "sellerProfile"
    },
    sellerProfile: function (username) {
        "use strict";
        var sellerProfile = new SellerProfileView({username: username});
    }
});

module.exports = Router


var Router = require('./router'),
    Backbone = require('backbone'),
    $ = require('jquery');

var app = {
    init: function () {
        "use strict";
        Backbone.$ = $;
        this.router = new Router();
        $(document).ready(function () {
            Backbone.history.start({ pushState: true, route: '/' });
        });
    }
};

module.exports = app;
app.init();

I get the below error if i refresh the page without the hash

Error response

Error code 404.

Message: File not found.

Error code explanation: 404 = Nothing matches the given URI.

Please help.


回答1:


pushState will try to load the ressource.And it seems your server is not loading anything at 'yourwebsiteurl.com/'



来源:https://stackoverflow.com/questions/38320519/backbone-route-with-push-state-not-working-on-page-refresh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!