我正在尝试从外部文件加载我的基因剔除模板。
我的设置如下:
现在,我尝试了几种不同的选择,但没有一种有效:
template: require("text-loader!./my-component.html")
// or
template: require("raw-loader!./my-component.html")
// or
template: require("html-loader!./my-component.html")
无效,因为这会返回类似于Javascript代码的文本,并且我的模板位于内部。
template: require("knockout-template-loader!html-loader!./my-component.html")
无效,因为它仅返回一个空对象。
template: require("script-template-loader?addToDom=true!./hello.html")
这有两个问题:
[object Object]
require
选项template: {require: "text-loader!./my-component.html"}
无法正常运行,因为我在运行时遇到错误:
无法读取位于以下位置的未定义的属性“调用”
__webpack_require__
我想念什么?
html-loader插件确实可以正常工作。一开始为什么不起作用的原因是我knockout-template-loader
在webpack.config.js中注册为html文件的默认加载器。
即使在require中指定了特定的加载器,它看起来也正在使用它。
删除该规则后,现在可以使用
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句