3

I'm just starting to play with Durandal, using the starter kit. I've added a very simple new view/viewmodel combination (essentially a copy/paste of an existing one from the sample) and mapNav()'d the route.

The problem is happening when I try to refresh my browser...the new view simply does not appear. It's not in the nav bar, nor can I navigate directly to the view by typing in the address bar. I know the code is (or should be?!) correct because if I go to the page in a different browser, everything appears as it should.

Is there some browser caching that Durandal is doing somehow? Sometimes F5 or Ctrl+F5 works to refresh, sometimes it doesn't. I also can't deep-link to a specific 'page'. Ie:

http://localhost:52625/#/newpage just gives me a blank

What am I missing?

4

2 回答 2

5

我在 Chrome 中使用的选项是打开开发人员工具并右键单击刷新按钮。有一个“空缓存和硬重新加载”选项,它总是为我解决这个问题。我不知道 IE 中的等价物,但试试这个,看看它是否能解决你的问题。

在此处输入图像描述

于 2013-05-14T14:52:58.373 回答
3

大多数浏览器会缓存通过 RequireJS 返回的模块,这是 Durandal 获取其模块和视图模型的方式。

CTRL+F5 没有帮助,因为它只是刷新了初始页面 - 所有模块仍然使用 javascript (RequireJS) 请求,因此通常首先从缓存中提取它们。

我发现最好在浏览器的开发人员工具中禁用缓存。这样做将确保所有网络请求都直接从源加载,而不是从缓存中加载。

有关其他信息,请参阅此问题: 使用 require.js 缓存时进行调试

另一种解决方案是配置 RequireJS 以设置其urlArgs属性: https ://stackoverflow.com/a/8479953/91189

该解决方案工作正常,但至少在 Chrome 中更难调试,因为每次加载模块时都会丢失断点,因为从技术上讲,每次请求的文件都不同。

于 2013-05-14T13:49:19.157 回答