首页 > 解决方案 > 在 webpack 中使用模板字符串 [Javascript]

问题描述

我对 webpack 还很陌生,在编译我的代码时遇到了这个错误。

ERROR in   Error: Child compilation failed:
Module build failed (from ../node_modules/html-loader/index.js):
Error: Line 539: Unexpected identifier

这也是它所指的线。

return `background: linear-gradient(to bottom right, ${this.gradientStart}, ${this.gradientEnd});`

是否可以在 Webpack 中允许模板字符串?这是我的 webpack 配置的内部

const html = {
  test: /\.(html)$/,
  // exclude: /\.html$/,
  use: [
  {
  loader: 'html-loader',
  options: {
    interpolate: true,
   },
  },
 ],
};

标签: javascriptnode.jswebpack

解决方案


推荐阅读