Webpack 4: Excel failed to load

pansfy
  • 2
新手上路,请多包涵

error in ./src/utils/template/Example.xls

Module parse failed: Unexpected character '�' (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concep... (Source code omitted for this binary file)

回复
阅读 1.1k
2 个回答

webpack 原生只认得 js(及衍生 ejs、mjs)、json,其它文件都要使用相应的 loader。你这里引用 excel 文件,就需要某种 excel-loader。

功能应该是下载模版文件吧,直接将文件放在pubilc文件目录下,再直接用 url 下载

let eleLink = document.createElement('a');
eleLink.href = url;
eleLink.style.display = 'none';
document.body.appendChild(eleLink);
eleLink.click();
document.body.removeChild(eleLink);
宣传栏