Home > Web Front-end > Vue.js > body text

Why does vue.js report an error?

藏色散人
Release: 2023-01-13 00:45:12
Original
2952 people have browsed it

vue.js reports an error because the project does not recognize the es6 expansion operator. The solution is to download the es6 dependencies through the "cnpm install babel-preset-es2015 --save-dev" method.

Why does vue.js report an error?

#The operating environment of this article: Windows7 system, vue2.0, Dell G3 computer.

Why does using the... operator in vue.js report an error?

vue.js reports an error when using the... operator: the project does not recognize the es6 expansion operator. The solution is very simple.

Solution:

// 第一步
cnpm install babel-plugin-transform-object-rest-spread
// 第二步 看一下你的 .babelrc 里面是否有识别es6语法的配置
{
 "presets": [
  ["env", {
   "modules": false,
   "targets": {
    "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
   }
  }],
  "stage-2"
 ],
 "presets": [
  ["es2015", { "modules": false }]
 ],
 "plugins": ["transform-object-rest-spread"]
}
Copy after login

After doing both, I found that another error was reported. The reason is that you only configured it. But there is no download of es6 dependencies

Just need to download

cnpm install babel-preset-es2015 --save-dev
Copy after login

and it will be ok!

Recommended: "vuejs tutorial"

The above is the detailed content of Why does vue.js report an error?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
vue
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template