【问题标题】:Durandal Child router not finding viewsDurandal 儿童路由器未找到视图
【发布时间】:2016-09-20 09:40:10
【问题描述】:

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

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

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

【问题讨论】:

    标签: javascript durandal durandal-navigation


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-27
      • 1970-01-01
      • 2020-08-23
      • 2019-10-19
      • 2021-12-07
      相关资源
      最近更新 更多