[英]Yeoman backbone view not rendering
I can't seem to figure out how to show the contents of the mvc files ie the views template and the routes. 我似乎无法弄清楚如何显示mvc文件的内容,即视图模板和路由。
I have this code in my /routes/application.js 我的/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});
})();
thanks 谢谢
I changed the router code generated by yo when I run the command yo backbone:all
to this 当我运行命令yo backbone:all
bone时,我更改了yo生成的路由器代码yo backbone:all
to this
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});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.