Backbone.js 用骨干力量发动行动

Backbone.js 用骨干力量发动行动,backbone.js,Backbone.js,Iv'e设置了我的第一个带有路由器的小型主干应用程序,看看我是否可以执行一些操作。我不能。我没有收到错误消息,但console.log消息未显示。要启动应用程序,我还需要设置其他设置吗 window.BreakfastApp = new (Backbone.Router.extend({ routes: { "": "interest", "products/:type": "products"}, initialize: function(){ console.log

Iv'e设置了我的第一个带有路由器的小型主干应用程序,看看我是否可以执行一些操作。我不能。我没有收到错误消息,但console.log消息未显示。要启动应用程序,我还需要设置其他设置吗

window.BreakfastApp = new (Backbone.Router.extend({
  routes: { "": "interest",  "products/:type": "products"},
  initialize: function(){    
    console.log("hello world");
  }, 
  start: function(){
    Backbone.history.start({pushState: true});     
  },
  interest: function(){
    console.log('interest')
  },
  products: function(type){
    console.log('product' + type )
  },
  toppings: function(){
    console.log('toppings')
  },
  results: function(){
    console.log('results')
  }
}));

$(function(){ 
 BreakfastApp.start(); 
});
报告说:

在页面加载期间,在应用程序完成所有页面的创建之后 它的路由器,请务必调用主干.history.start(),或 start({pushState:true})来路由初始URL

在您的情况下,类似于:

var BreakfastAppRouter = Backbone.Router.extend({
    ...
});
var router = new BreakfastAppRouter();
Backbone.history.start();
我应该做这项工作