导航到Durandal中的视图时,无法读取未定义的属性“cacheViews”

时间:2013-12-23 18:36:56

标签: durandal

这工作得很好。我认为错误首次出现在我为其中一个撰写项目添加“cacheviews:true”的时候:

  <div id="leftCol">
      <section id="content-left">
        <div data-bind="compose: { model: leftColTree, preserveContext: true, cacheViews: true }"></div>
      </section>
  </div>

目前我有三种观点。我可以刷新当前视图并导航到另一个视图,但是一旦完成,我就无法在不触发标题错误的情况下转到任何其他视图。我意识到这很难诊断,但如果有人对导致这个错误的一般事情有一些建议,那么我将非常感谢!

EDIT 为了澄清,这在“composition.js”(第352行)中是错误的,这是下面的第2行。

var instruction = binder.getBindingInstruction(context.activeView);
if(instruction.cacheViews != undefined && !instruction.cacheViews){

1 个答案:

答案 0 :(得分:1)

在composition.js中的完全相同的位置有同样的错误信息。

对于我来说,在shell.html中将cacheViews从true更改为false就可以了。

`<div>
    <header data-bind="compose: { view: 'nav' }"></header>
    <section id="content" class="main container-fluid"
        data-bind="router: { transition: 'entrance', cacheViews: true }">
    </section>
    <footer data-bind="compose: { view: 'footer' }"></footer>
</div>`

到此:

`<div>
    <header data-bind="compose: { view: 'nav' }"></header>
    <section id="content" class="main container-fluid"
        data-bind="router: { transition: 'entrance', cacheViews: false}">
    </section>
    <footer data-bind="compose: { view: 'footer' }"></footer>
</div>`