我搜索了各种其他类似的 StackOverflow 问题,但似乎都没有提供解决方案。我有以下骨干路由器设置:
var AppRouter = Backbone.Router.extend({
routes: {
"" : "homeAction",
"/portfolio" : "portfolioAction",
"/about_us" : "aboutUsAction",
"/contact" : "contactAction"
},
initialize: function () {
},
homeAction: function () {
alert("User has navigated home");
},
portfolioAction : function() {
alert('user have navigated to portfolio');
},
servicesAction: function () {
alert("User has navigated to services");
},
aboutUsAction: function () {
alert("User has navigated to about us");
},
contactAction: function () {
alert("User has navigated home");
},
requestQuoteAction: function () {
alert("User has requested to submit a quote");
}
});
var app = new AppRouter();
$(function() {
Backbone.history.start();
});
当我导航到 mydomain.com/# homeAction 路由按预期调用。但是,如果我尝试导航到 mydomain.com/#/portfolio,则没有任何反应。知道为什么没有调用此方法吗?