【问题标题】:KnockoutJS rendering external Templates dynamicallyKnockoutJS 动态渲染外部模板
【发布时间】:2013-01-18 02:18:47
【问题描述】:

我正在使用 KnockoutJS 开发 SPA,并在 KnockoutJS 中呈现外部模板时遇到问题。

我正在使用 Jim Cowart 的 External Template Engine。 https://github.com/ifandelse/Knockout.js-External-Template-Engine

这个绑定:

<div data-bind='template: {name: 'template1', templateUrl:"/dynamicviewtemplate"}'></div>

有效。而这个:

<div data-bind='template: {name: templateName, templateUrl:"/dynamicviewtemplate"}'></div>

不工作。

模板不会根据 observable 加载。

【问题讨论】:

    标签: knockout.js template-engine


    【解决方案1】:

    template 绑定不会自动解开 name 字段。您可以通过指定绑定来解决此问题:

    data-bind='template: {name: templateName(), templateUrl:"/dynamicviewtemplate"}'
    

    【讨论】:

      猜你喜欢
      • 2020-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-25
      • 2013-08-02
      • 1970-01-01
      • 1970-01-01
      • 2012-03-07
      相关资源
      最近更新 更多