[英]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.