當我嘗試使用兒童路線時,我收到「路線未找到」。爲了涵蓋我的基礎,下面是如何設計應用程序中的路由。Durandal兒童路線未找到路線錯誤
的main.js文件包含路由爲頂級導航和被原樣
router.map([
{ route: 'LOC', moduleId: 'LOC', title: 'LC', nav: 3 }
]);
我的頁面的頁腳原樣
router.map('About', 'About', 'About', false);
router.map('Help', 'Help', 'Help', false);
當用戶點擊地圖上的路線進行上面創建的'LOC'路線,左側導航顯示在該視圖上。這種觀點用孩子路由和設置AS-
var childRouter = router.createChildRouter()
.makeRelative({
moduleId: 'viewmodels/',
fromParent: true
}).map([
{ route: '*LCClientSearch', moduleId: 'LCClientSearch', title: 'Create LC', type: 'intro', hash: '#LCClientSearch', nav: true },
{ route: '*LCPending', moduleId: 'LCPending', title: 'Pending LC', type: 'intro', hash: '#LCPending', nav: true }
]).buildNavigationModel();
LOC默認爲LCClientSearch路線,並顯示正確的開始,但是,沒有合適的,從這一點上發生。當用戶點擊LCClientSearh或LCPending時,我得到'路由未找到'的錯誤。
LOC視圖 -
<div class="span2 well">
<ul class="nav nav-list">
<li class="nav-header">Availability</li>
<!--ko foreach: availability-->
<li data-bind="css: { active: isActive }">
<a data-bind="attr: { href: hash }, text: title"></a>
</li>
<!--/ko-->
<li class="nav-header">Manual Post</li>
<!--ko foreach: ManualPost-->
<li data-bind="css: { active: isActive }">
<a data-bind="attr: { href: hash }, text: title"></a>
</li>
<!--/ko-->
</ul>
</div>
爲什麼我得到的路線沒有發現?
我認爲你的子路由器中的moduleId應該是'LOC'而不是viewmodels。 – nimgrg
@nimgrg我改變了模塊,但仍然無法正常工作。第一次加載頁面時,它實際上會加載LCClientSearch視圖。所以,它在頁面加載時找到子路由,只是點擊子路由鏈接時導航不起作用。 – Chris