1

我正在尝试从John Papa 的网站复制一个 SPA 应用程序。我被困在使用 Durandal 撰写视图中。

我的主视图代码如下。根据 Durandal 的要求,我只有一个根级别,所以我不确定为什么我的两个撰写视图没有显示。如果我删除<h2>'s data-bind,那么世界上一切都很好。任何帮助或见解将不胜感激。

<section> 
    <div id="intro">
        <h2 data-bind="html: displayName"></h2>
        <blockquote class="text-left">
            The electronic Cognitive Preference Estimator (e-CPE) provides insight into your preferred approach to problem solving and change management. 
            It takes just a few minutes to register and less than five minutes to complete the instrument.<br />
        </blockquote>
    </div>
<section  style="clear: both;" data-bind="compose: { view: 'bio' }"></section>
<footer data-bind="compose: { view: 'footer' }"></footer>
</section>
4

1 回答 1

0

当您从 HTML 中显示简单视图时,您应该能够使用组合模块来执行此操作。如果您的子视图之一有绑定错误,它将停止渲染其他视图及其绑定,但您应该在控制台中看到它。

仅供参考,当我只是显示一个绑定到当前上下文的视图时,我这样做 -

<!-- ko compose: 'shell/navbar.html' --><!-- /ko -->

其中 shell 是我的视图文件夹中的一个文件夹,而 navbar.html 包含我的导航栏。

要确保的另一件事是您的 shell.js 视图模型正在公开一个 displayName 属性,该属性具有语义上正确的 HTML(如果有)。还要仔细检查 bio 和 footer 没有抛出任何绑定错误。

于 2013-09-22T20:04:49.537 回答