Solve the problem of using elementUi package to report errors in vue2

  • 2021-08-28 18:48:27
  • OfStack

bug1. element-ui/lib/theme-default/index. css not found

Resolution: Modify the path to element-ui/lib/theme-chalk/index. css

Reason: bug left over from elementUi upgrade

bug2: ERROR in static/js/app.77ab8a3664d32f2b9c76.js from UglifyJs

Unexpected token: operator ( > ) [./~/element-ui/src/mixins/emitter.js:2,0][assets/js/0.498ce690b229694d8858.js:3947,32

Solution: Open the file webpack. base. conf. js in the build directory

Add


{
 test: /\.js$/i,
 loader: 'babel-loader',
 include: [
  resolve('src'),
  resolve('test'),
  resolve('node_modules/element-ui/src/mixins/emitter.js'),
 ],
},

If there are similar errors in repeating build, add


 test: /\.js$/i,
 loader: 'babel-loader',
 include: [
  resolve('src'),
  resolve('test'),
  resolve('node_modules/element-ui/src'),
  resolve('node_modules/element-ui/packages')
 ],
},

Supplementary knowledge: vue scaffold loading element-ui error reporting solution

After the introduction of import 'element-ui/lib/theme-chalk/index. css'

All kinds of error reporting and solutions

1. cnpm install css-loader style-loader file-loader-D

2. Add one line of rules to webpack. config. js

{test: /\.(eot|woff|ttf)$/, loader: "file-loader" }

3. npm run dev

Note: {test:/\. css $/, loader: 'style-loader! css-loader'} This 1 line does not have to be added, but it runs incorrectly when I add this 1 line, so I can't write it like this {test:/\. css $/, loader: 'style! css'}


Related articles: