将dom节点传递到Knockout组件中(当使用RequireJS时)

Passing dom nodes into a Knockout component (when using RequireJS)

本文关键字:RequireJS 组件 节点 dom Knockout      更新时间:2023-09-26

我正试图用requireJS将此示例转换为AMD。

作为一个例子,我选择了"基本窗口"小部件:

<base-window params="title: 'Window title'">
    <h1 data-bind="text: title"></h1>
    <p>This is a body of the window</p>
</base-window>

请参阅plunk。

但是,没有显示窗口的主体。浏览器显示:

Uncaught ReferenceError: Unable to process binding "template: function (){return {nodes:$componentTemplateNodes} }"
Message: $componentTemplateNodes is not defined

有人能说出怎么了吗?

上下文变量$componentTemplateNodes仅从KO 3.3版开始可用

Plunk