停止KnockoutJS使用jQuery.tmpl

Mik*_*vis 4 jquery-templates knockout.js

我正在将Knockout添加到大型应用程序的特定部分.其他部分使用jQuery模板(并且它嵌入在基础JS文件中),所以它在全局jQuery对象上,我无法删除它.

foreach在模板中使用绑定时遇到以下错误消息:

This template engine does not support the 'foreach' binding within its templates 
Run Code Online (Sandbox Code Playgroud)

当使用带有Knockout的jQuery模板引擎时,这似乎是一个问题.有没有办法让Knockout使用其默认模板引擎而不是jQuery模板?

RP *_*yer 13

您可以ko.setTemplateEngine(new ko.nativeTemplateEngine());在致电前使用ko.applyBindings.