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