在使用element-ui按需導入時,出現以下錯誤:
These dependencies were not found: * fonts/element-icons.ttf in ./node_modules/_css-loader@1.0.1@css-loader??ref--6-oneOf-3-1!./node_modules/_postcss-loader@3.0.0@postcss-loader/src??ref-- 6-oneOf-3-2!./node_modules/_element-ui@2.13.0@element-ui/lib/theme-chalk/index.css * fonts/element-icons.woff in ./node_modules/_css-loader@1.0.1@css-loader??ref--6-oneOf-3-1!./node_modules/_postcss-loader@3.0.0@postcss-loader/src??ref- -6-oneOf-3-2!./node_modules/_element-ui@2.13.0@element-ui/lib/theme-chalk/index.css To install them, you can run: npm install --save fonts/element-icons.ttf fonts/element-icons.woff
解決錯誤
出現錯誤的主要原因是在 vue.config.js 配置文件中設置了 css.modules = true,這個默認的值為 false ,只要把這個設置去掉問題即可得到解決