有没有办法用Web包装你的HTML,所以你有HTML块而不是大的HTML文件?
示例:
<html>
<body>
<div>Here is the main page </div>
<script>
// inject a chunk of HTML here
require.include('./header.html');
</script>
</body>
</html>
我看到了HTML加载器,但我不认为我可以将它用于此目的。
答案 0 :(得分:-2)
也许你需要这个html-loader
编辑:
您可以使用interpolate标志为ES6模板字符串启用插值语法,如下所示:
require("html?interpolate!./file.html");
<img src="${require(`./images/gallery.png`)}" />
<div>${require('./partials/gallery.html')}</div>