Durandal Child路由器找不到视图

时间:2016-09-20 09:40:11

标签: javascript durandal durandal-navigation

在我讨论这个问题之前,我的项目结构概述

-- Common
    --services
    --views
    --viewmodels
 -- Product1
    --services
    --views
        -- mywork
            -- overview.html
            -- sections
                -- audit.html
                -- completed.html
                -- attention.html
                -- index.html
    --viewmodels
        -- mywork
            -- overview.js
            -- sections
                -- audit.js
                -- completed.js
                -- attention.js
                -- index.js

现在我在Product1中设置了一个名为mywork的部分,其中包含一个子路由器。 shell.js中的核心路由是使用splat设置的。

{ route: 'myWork*details', moduleId: 'product1/viewmodels/myWork/overview', title: 'My Work' }

然后将子路径创建为

var childRouter = router.createChildRouter()
            .makeRelative({ moduleId: 'product1/viewmodels/mywork/sections', fromParent: true })
            .map([
                { route: [''], moduleId: 'index', title: 'Overview', icon: 'fa-cogs', nav: false },
                { route: 'audits', moduleId: 'audits', title: 'Audits', icon: 'fa-list', nav: true },
                { route: 'completed', moduleId: 'completed', title: 'Tracked Records', icon: 'fa-list', nav: true },
                { route: 'attention', moduleId: 'attention', title: 'Requires Attention', icon: 'fa-list', nav: true }
            ]).buildNavigationModel();

主要问题是,当通过导航栏访问任何页面时,我发出错误...

View Not Found. Searched for "product1/views/mywork/sections/audits" via path "text!product1/views/mywork/sections/audits.html".

然而,概览页面的视图可以通过路径['']正常工作。关于为什么我的其他视图找不到的任何想法,即使视图模型是什么,文本是什么!在错误路径之前?

1 个答案:

答案 0 :(得分:0)

注意,子路由在html文件中至少需要一个<div></div>标记,我认为是由于某种类型的id分配,否则子路由器将找不到该视图。