今天用 Vue 脚手架 Vue CLI 拉了一个 express 项目, npm run dev
运行时报错:
详细报错内容如下:
WARNING Compiled with 3 warnings 22:30:22 ✘ http://eslint.org/docs/rules/comma-dangle Unexpected trailing comma src\components\HelloWorld.vue:92:15 data: [], ^ ✘ 1 problem (1 error, 0 warnings) Errors: 1 http://eslint.org/docs/rules/comma-dangle ✘ http://eslint.org/docs/rules/space-before-function-paren Missing space before function parentheses src\App.vue:11:10 mounted(){ ^ ✘ http://eslint.org/docs/rules/space-before-blocks Missing space before opening brace src\App.vue:11:12 mounted(){ ^ ✘ http://eslint.org/docs/rules/quotes Strings must use singlequote src\App.vue:12:20 this.axios.get("api/list").then((res)=>{ ^ ✘ http://eslint.org/docs/rules/arrow-spacing Missing space before => src\App.vue:12:41 this.axios.get("api/list").then((res)=>{ ^ ✘ http://eslint.org/docs/rules/arrow-spacing Missing space after => src\App.vue:12:44 this.axios.get("api/list").then((res)=>{ ^ ✘ http://eslint.org/docs/rules/semi Extra semicolon src\App.vue:13:23 console.log(res); ^ ✘ 6 problems (6 errors, 0 warnings) Errors: 2 http://eslint.org/docs/rules/arrow-spacing 1 http://eslint.org/docs/rules/space-before-function-paren 1 http://eslint.org/docs/rules/space-before-blocks 1 http://eslint.org/docs/rules/quotes 1 http://eslint.org/docs/rules/semi ✘ https://google.com/#q=import%2Ffirst Import in body of module; reorder to top src\main.js:9:1 import axios from 'axios'; ^ ✘ http://eslint.org/docs/rules/semi Extra semicolon src\main.js:9:26 import axios from 'axios'; ^ ✘ http://eslint.org/docs/rules/semi Extra semicolon src\main.js:10:28 Vue.prototype.axios = axios; ^ ✘ 3 problems (3 errors, 0 warnings) Errors: 2 http://eslint.org/docs/rules/semi 1 https://google.com/#q=import%2Ffirst You may use special comments to disable some warnings. Use // eslint-disable-next-line to ignore the next line. Use /* eslint-disable */ to ignore all warnings in a file.
解决方法:
找到项目 config 文件夹下的 index.js 文件,将 useEslint
的值修改为 false
即可: