Yeoman骨干视图无法渲染

时间:2014-01-13 05:45:45

标签: javascript backbone.js yeoman backbone-routing

我似乎无法弄清楚如何显示mvc文件的内容,即视图模板和路径。

我在/routes/application.js

中有这段代码
sample.Routers = sample.Routers || {};

(function () {
    'use strict';

    sample.Routers.ApplicationRouter = Backbone.Router.extend({
        routes: {
        '' : function () {
            alert('Home');
        },
        'view': function () {
            alert('View');
        }
    }

    });
    Backbone.history.start({pushState: true});

})();

感谢

1 个答案:

答案 0 :(得分:0)

当我将命令yo backbone:all运行到此

时,我更改了 yo 生成的路由器代码
 var AppRouter = Backbone.Router.extend ({

routes: {
    '' : 'home',
    'view': 'viewImage'
}
});

var appRouter = new AppRouter();

appRouter.on('route:home', function () {
    console.log('im home');
});

appRouter.on('route:viewImage', function() {
    alert('hey');
    // console.log('view');
});


Backbone.history.start({pushState: true});