0
我在VS 2012中使用hottowel 2.0.1創建了一個項目,並且在HotTowel課程/示例後面有以下代碼。但是我有以下錯誤。未捕獲類型錯誤:對象#<Object>沒有方法'navigateTo'?
Uncaught TypeError: Object # has no method 'navigateTo' ?
我設置在該行一個破發點,發現路由器沒有方法navigateTo
。但是,它的方法有navigate
。名稱是否改變?
define(['services/datacontext', 'plugins/router', 'services/logger'],
function (datacontext, router, logger) {
......
var gotoDetails = function (selectedEvent) {
if (selectedEvent && selectedEvent.Id()) {
var url = '#/eventdetail/' + selectedEvent.Id();
router.navigateTo(url);
}
};
var viewAttached = function (view) {
bindEventToList(view, '.event-brief', gotoDetails);
};
var bindEventToList = function (rootSelector, selector, callback, eventName) {
var eName = eventName || 'click';
$(rootSelector).on(eName, selector, function() {
var event = ko.dataFor(this);
callback(event);
return false;
});
};
//#endregion
var vm = {
activate: activate,
deactivate: deactivate,
refresh: refresh,
events: events,
title: title,
attached: viewAttached
};
return vm;
});