index.html<div class="center-table-wrapper">
<%= require('html-loader!../components/systemMainTab/index.html') %></div>systemMainTab/index.html<div class="containerDY">
<div class="container-list">
<div class="container-table">
<table id="showTable" style="width:100%"></table>
</div>
<div class="container-pagination">
<!-- 無法引入html 內容 -->
<%= require('html-loader!../systemPagination/index.html') %>
</div>
</div>
<!-- <div class="container-dy">
</div> --></div>systemPagination/index.html<div class="system-pagination"></div>第一層 <%= require('html-loader!../components/systemMainTab/index.html') %> 能正常引入, 而systemMainTab/index.html 的 <%= require('html-loader!../systemPagination/index.html') %> 未能解析, 有什么方法能嵌套解析否?一種方式是通過 js 來引入模塊在組裝, 不過這種方式實現不佳
1 回答

慕標5832272
TA貢獻1966條經驗 獲得超4個贊
你既然已經用了 html-loader
了,實際上就不需要通過 html-webpack-plugin
的模板來渲染 html 了。在 webpack 里配置 html-loader
開啟 interpolate 后,通過 ES6 字符串模板進行引用。
webpack:
{ test: /\.html$/, use: [{ loader: "html-loader", options: { interpolate: true } }]}
html:
<!DOCTYPE html><html lang="en"><head> ${require("./common.html")}</head>
然后在 common.html 中,可以繼續使用 ${require("xxx.html")} 進行引用。這個寫起來應該比你用 <%= ... %>
更簡潔一些。
- 1 回答
- 0 關注
- 1692 瀏覽
添加回答
舉報
0/150
提交
取消