【问题标题】:Upgrading to Durandal 2.0 from 1.2 - shell.html not found从 1.2 升级到 Durandal 2.0 - 找不到 shell.html
【发布时间】:2013-11-01 04:35:40
【问题描述】:

我在尝试激活我的 shell 时遇到 404 错误。它似乎找到了shell.js,但随后表明它找不到shell.html,因为它在错误的地方寻找!

我尝试强制约定明确告诉它在哪里查看,但它仍然无法正常工作。像这样:viewLocator.useConvention('viewmodels', 'views', '');

但我仍然得到:

App/viewmodels/shell.html 404 (Not Found)

显然它不应该在 app/viewmodels/ 中查找,它应该在 app/views/ 中查找

我的项目中的不同之处在于我没有将“/scripts/”文件夹用于 3rd 方的东西,我使用的是我自己的名为“/content/”的文件夹。我还将与 durandal 相关的几乎所有内容都放在“/app/”文件夹中。

这是我项目中一些关键文件的结构:

+app (folder)
  main.js
  > durandal (folder)
     app.js
     r.js
     require.js
     text.js
     viewEngine.js
     viewLocator.js
 > plugins (folder)
     router.js
 > viewmodels (folder)
     shell.js
 > views (folder)
     shell.html

在 main.js > 这是我设置要调用的外壳的地方: app.setRoot('viewmodels/shell');

这也是 main.js 中的路径:

paths: {
        'text': 'durandal/text',
        'durandal': 'durandal',
        'plugins': 'durandal/plugins',
        'transitions': 'durandal/transitions'
}

在 shell.js 中 > 好吧,这并不重要,因为此时它已经抛出了 404。

有什么想法吗?

【问题讨论】:

  • pluginstext 的路径看起来不正确。如果baseUrl 是app,那么它应该是'plugins' : 'plugins''text' : 'text'
  • 好主意,但他们是正确的。从我上面的图中有点不清楚,但路径实际上是“app > durandal”和下面的“plugins”目录。如果我删除“durandal/”部分,它不会找到文件并在我已经得到的文件之上抛出 404 错误。

标签: asp.net-mvc-4 durandal


【解决方案1】:

我现在明白了。我在 main.js 中定义的模块的路径错误。不知道为什么他们没有抛出错误,但无论如何,这就是我改变的:

来自: define(['../app/durandal/system', '../app/durandal/app', '../app/durandal/viewLocator'], function (system, app, viewLocator) {

到: define(['durandal/system', 'durandal/app', 'durandal/viewLocator'], function (system, app, viewLocator) {

现在似乎可以工作了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-09-24
    • 1970-01-01
    • 2011-12-26
    • 2018-05-02
    • 2015-09-04
    • 1970-01-01
    • 2023-03-16
    • 1970-01-01
    相关资源
    最近更新 更多