[英]Why I get a location string when requiring a html file in webpack?
var uib = $uibModal.open(
{
template: require('./create/create.html'),
}
)
我想要在create.html中获取内容并以模式显示它,但它显示./create/create.html
(模式中位置的字符串)。
我在webpack.config.js中添加了html loader:
{
test: /\.html$/,
loader: 'raw-loader',
},
您应该使用templateUrl
var uib = $uibModal.open({
templateUrl: require('./create/create.html'),
});
当您想在js
中声明html代码时,可以使用template
但是如果您想在create.html
调用诸如create.html
类的html页面,则必须通过templateUrl
进行调用
您也可以在template
编写代码,例如:
var uib = $uibModal.open({
template: '<html><h3> Hie i am in js </h3></html>'
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.