私はbackbone.jsを使用して最初のJavaScriptアプリを作成しようとしましたが、奇妙な動作を見つけました。2つのコードの違いがわかりません。1つはうまく機能し、2つ目は機能しないようです。
ホームページと「#test」URLにアラートを表示します
var AppRouter = Backbone.Router.extend({
routes:{
"": 'index',
"test": 'test'
},
index: function(){
alert('index');
},
test: function(){
alert('test');
}
});
var app = new AppRouter();
Backbone.history.start();
そしてそれは機能しませんが、Backbone.history.hanlers
同じように見えます
var router = new Backbone.Router({
routes:{
"": 'index',
"test": 'test'
},
index: function(){
alert('index');
},
test: function(){
alert('test');
}
});
Backbone.history.start();