Home>Article>Web Front-end> Why does vue.js report an error?

Why does vue.js report an error?

藏色散人
藏色散人 Original
2021-02-07 10:09:46 2877browse

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"] }

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

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!

Statement:
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
Previous article:What is vue.use Next article:What is vue.use