0

在我进入这个问题之前,这里是我的项目结构的概述

-- 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".

然而,概览页面的视图工作正常,由路线 [''] 定义。关于为什么我的其他视图没有找到的任何想法,即使视图模型是并且什么是文本!在错误的路径之前?

4

1 回答 1

0

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

于 2016-09-20T10:29:26.020 回答