自己从网上找来个实战项目,npm install之后,启动项目,出现了下面这么多的警告和报错,一脸懵逼:

Windows PowerShell
版权所有 (C) Microsoft Corporation。保留所有权利。

PS F:\vue.news-master> npm run dev

> vue.news@2.0.0 dev F:\vue.news-master
> webpack-dev-server --open --inline --progress --config build/webpack.dev.conf.js

 95% emitting

 WARNING  Compiled with 2 warnings                                                                                                                         15:04:08

  ✘  http://eslint.org/docs/rules/indent                   Expected indentation of 0 spaces but found 1
  src\App.vue:15:1
   /*全局引入VueAwesomeSwiper轮播图插件*/
   ^

  ✘  http://eslint.org/docs/rules/spaced-comment           Expected exception block, space or tab after '/*' in comment
  src\App.vue:15:2
   /*全局引入VueAwesomeSwiper轮播图插件*/
    ^

  ✘  http://eslint.org/docs/rules/spaced-comment           Expected space or tab before '*/' in comment
  src\App.vue:15:2
   /*全局引入VueAwesomeSwiper轮播图插件*/
    ^

  ✘  http://eslint.org/docs/rules/no-unused-vars           'VueAwesomeSwiper' is defined but never used
  src\App.vue:16:8
  import VueAwesomeSwiper from 'vue-awesome-swiper';
          ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:16:50
  import VueAwesomeSwiper from 'vue-awesome-swiper';
                                                    ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:17:36
  import 'swiper/dist/css/swiper.css';//这里注意具体看使用的版本是否需要引入样式,以及具体位置。
                                      ^

  ✘  http://eslint.org/docs/rules/spaced-comment           Expected space or tab after '//' in comment
  src\App.vue:17:37
  import 'swiper/dist/css/swiper.css';//这里注意具体看使用的版本是否需要引入样式,以及具体位置。
                                       ^

  ✘  http://eslint.org/docs/rules/no-multiple-empty-lines  More than 1 blank line not allowed
  src\App.vue:18:1

   ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:20:47
  import AppHead from '@/components/public/Head';
                                                 ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:21:47
  import AppMenu from '@/components/public/Menu';
                                                 ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:22:45
  import AppNav from '@/components/public/Nav';
                                               ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:23:47
  import AppFoot from '@/components/public/Foot';
                                                 ^


✘ 12 problems (12 errors, 0 warnings)


Errors:
  6  http://eslint.org/docs/rules/semi
  3  http://eslint.org/docs/rules/spaced-comment
  1  http://eslint.org/docs/rules/no-multiple-empty-lines
  1  http://eslint.org/docs/rules/no-unused-vars
  1  http://eslint.org/docs/rules/indent


  ✘  http://eslint.org/docs/rules/semi            Extra semicolon
  src\components\Select.vue:40:36
  import 'swiper/dist/css/swiper.css';这里注意具体看使用的版本是否需要引入样式,以及具体位置。
                                      ^

  ✘  http://eslint.org/docs/rules/spaced-comment  Expected space or tab after '///' in comment
  src\components\Select.vue:40:37
  import 'swiper/dist/css/swiper.css';这里注意具体看使用的版本是否需要引入样式,以及具体位置。
                                       ^

  ✘  http://eslint.org/docs/rules/semi            Extra semicolon
  src\components\Select.vue:41:57
  import { swiper, swiperSlide } from 'vue-awesome-swiper';
                                                           ^

  ✘  http://eslint.org/docs/rules/semi            Extra semicolon
  src\components\Select.vue:43:58
  import { mapState, mapMutations, mapActions } from 'vuex';
                                                            ^


✘ 4 problems (4 errors, 0 warnings)


Errors:
  3  http://eslint.org/docs/rules/semi
  1  http://eslint.org/docs/rules/spaced-comment

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.

 WAIT  Compiling...                                                                                                                                        15:05:01
 95% emitting

 WARNING  Compiled with 2 warnings                                                                                                                         15:05:02

  ✘  http://eslint.org/docs/rules/no-unused-vars           'VueAwesomeSwiper' is defined but never used
  src\App.vue:16:8
  import VueAwesomeSwiper from 'vue-awesome-swiper';
          ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:16:50
  import VueAwesomeSwiper from 'vue-awesome-swiper';
                                                    ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:17:36
  import 'swiper/dist/css/swiper.css';//这里注意具体看使用的版本是否需要引入样式,以及具体位置。
                                      ^

  ✘  http://eslint.org/docs/rules/spaced-comment           Expected space or tab after '//' in comment
  src\App.vue:17:37
  import 'swiper/dist/css/swiper.css';//这里注意具体看使用的版本是否需要引入样式,以及具体位置。
                                       ^

  ✘  http://eslint.org/docs/rules/no-multiple-empty-lines  More than 1 blank line not allowed
  src\App.vue:18:1

   ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:20:47
  import AppHead from '@/components/public/Head';
                                                 ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:21:47
  import AppMenu from '@/components/public/Menu';
                                                 ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:22:45
  import AppNav from '@/components/public/Nav';
                                               ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:23:47
  import AppFoot from '@/components/public/Foot';
                                                 ^


✘ 9 problems (9 errors, 0 warnings)


Errors:
  6  http://eslint.org/docs/rules/semi
  1  http://eslint.org/docs/rules/no-multiple-empty-lines
  1  http://eslint.org/docs/rules/spaced-comment
  1  http://eslint.org/docs/rules/no-unused-vars


  ✘  http://eslint.org/docs/rules/semi            Extra semicolon
  src\components\Select.vue:40:36
  import 'swiper/dist/css/swiper.css';这里注意具体看使用的版本是否需要引入样式,以及具体位置。
                                      ^

  ✘  http://eslint.org/docs/rules/spaced-comment  Expected space or tab after '///' in comment
  src\components\Select.vue:40:37
  import 'swiper/dist/css/swiper.css';这里注意具体看使用的版本是否需要引入样式,以及具体位置。
                                       ^

  ✘  http://eslint.org/docs/rules/semi            Extra semicolon
  src\components\Select.vue:41:57
  import { swiper, swiperSlide } from 'vue-awesome-swiper';
                                                           ^

  ✘  http://eslint.org/docs/rules/semi            Extra semicolon
  src\components\Select.vue:43:58
  import { mapState, mapMutations, mapActions } from 'vuex';
                                                            ^


✘ 4 problems (4 errors, 0 warnings)


Errors:
  3  http://eslint.org/docs/rules/semi
  1  http://eslint.org/docs/rules/spaced-comment

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.

 WAIT  Compiling...                                                                                                                                        15:05:05
 95% emitting

 WARNING  Compiled with 2 warnings                                                                                                                         15:05:06

  ✘  http://eslint.org/docs/rules/no-unused-vars           'VueAwesomeSwiper' is defined but never used
  src\App.vue:16:8
  import VueAwesomeSwiper from 'vue-awesome-swiper';
          ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:16:50
  import VueAwesomeSwiper from 'vue-awesome-swiper';
                                                    ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:17:36
  import 'swiper/dist/css/swiper.css';//这里注意具体看使用的版本是否需要引入样式,以及具体位置。
                                      ^

  ✘  http://eslint.org/docs/rules/spaced-comment           Expected space or tab after '//' in comment
  src\App.vue:17:37
  import 'swiper/dist/css/swiper.css';//这里注意具体看使用的版本是否需要引入样式,以及具体位置。
                                       ^

  ✘  http://eslint.org/docs/rules/no-multiple-empty-lines  More than 1 blank line not allowed
  src\App.vue:18:1

   ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:20:47
  import AppHead from '@/components/public/Head';
                                                 ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:21:47
  import AppMenu from '@/components/public/Menu';
                                                 ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:22:45
  import AppNav from '@/components/public/Nav';
                                               ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:23:47
  import AppFoot from '@/components/public/Foot';
                                                 ^


✘ 9 problems (9 errors, 0 warnings)


Errors:
  6  http://eslint.org/docs/rules/semi
  1  http://eslint.org/docs/rules/no-multiple-empty-lines
  1  http://eslint.org/docs/rules/spaced-comment
  1  http://eslint.org/docs/rules/no-unused-vars


  ✘  http://eslint.org/docs/rules/semi            Extra semicolon
  src\components\Select.vue:40:36
  import 'swiper/dist/css/swiper.css';这里注意具体看使用的版本是否需要引入样式,以及具体位置。
                                      ^

  ✘  http://eslint.org/docs/rules/spaced-comment  Expected space or tab after '///' in comment
  src\components\Select.vue:40:37
  import 'swiper/dist/css/swiper.css';这里注意具体看使用的版本是否需要引入样式,以及具体位置。
                                       ^

  ✘  http://eslint.org/docs/rules/semi            Extra semicolon
  src\components\Select.vue:41:57
  import { swiper, swiperSlide } from 'vue-awesome-swiper';
                                                           ^

  ✘  http://eslint.org/docs/rules/semi            Extra semicolon
  src\components\Select.vue:43:58
  import { mapState, mapMutations, mapActions } from 'vuex';
                                                            ^


✘ 4 problems (4 errors, 0 warnings)


Errors:
  3  http://eslint.org/docs/rules/semi
  1  http://eslint.org/docs/rules/spaced-comment

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.

 WAIT  Compiling...                                                                                                                                        15:05:07
 95% emitting

 WARNING  Compiled with 2 warnings                                                                                                                         15:05:08

  ✘  http://eslint.org/docs/rules/no-unused-vars           'VueAwesomeSwiper' is defined but never used
  src\App.vue:16:8
  import VueAwesomeSwiper from 'vue-awesome-swiper';
          ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:16:50
  import VueAwesomeSwiper from 'vue-awesome-swiper';
                                                    ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:17:36
  import 'swiper/dist/css/swiper.css';//这里注意具体看使用的版本是否需要引入样式,以及具体位置。
                                      ^

  ✘  http://eslint.org/docs/rules/spaced-comment           Expected space or tab after '//' in comment
  src\App.vue:17:37
  import 'swiper/dist/css/swiper.css';//这里注意具体看使用的版本是否需要引入样式,以及具体位置。
                                       ^

  ✘  http://eslint.org/docs/rules/no-multiple-empty-lines  More than 1 blank line not allowed
  src\App.vue:18:1

   ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:20:47
  import AppHead from '@/components/public/Head';
                                                 ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:21:47
  import AppMenu from '@/components/public/Menu';
                                                 ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:22:45
  import AppNav from '@/components/public/Nav';
                                               ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:23:47
  import AppFoot from '@/components/public/Foot';
                                                 ^


✘ 9 problems (9 errors, 0 warnings)


Errors:
  6  http://eslint.org/docs/rules/semi
  1  http://eslint.org/docs/rules/no-multiple-empty-lines
  1  http://eslint.org/docs/rules/spaced-comment
  1  http://eslint.org/docs/rules/no-unused-vars


  ✘  http://eslint.org/docs/rules/semi            Extra semicolon
  src\components\Select.vue:40:36
  import 'swiper/dist/css/swiper.css';这里注意具体看使用的版本是否需要引入样式,以及具体位置。
                                      ^

  ✘  http://eslint.org/docs/rules/spaced-comment  Expected space or tab after '///' in comment
  src\components\Select.vue:40:37
  import 'swiper/dist/css/swiper.css';这里注意具体看使用的版本是否需要引入样式,以及具体位置。
                                       ^

  ✘  http://eslint.org/docs/rules/semi            Extra semicolon
  src\components\Select.vue:41:57
  import { swiper, swiperSlide } from 'vue-awesome-swiper';
                                                           ^

  ✘  http://eslint.org/docs/rules/semi            Extra semicolon
  src\components\Select.vue:43:58
  import { mapState, mapMutations, mapActions } from 'vuex';
                                                            ^


✘ 4 problems (4 errors, 0 warnings)


Errors:
  3  http://eslint.org/docs/rules/semi
  1  http://eslint.org/docs/rules/spaced-comment

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.

 WAIT  Compiling...                                                                                                                                        15:05:09
 95% emitting

 WARNING  Compiled with 2 warnings                                                                                                                         15:05:09

  ✘  http://eslint.org/docs/rules/no-unused-vars           'VueAwesomeSwiper' is defined but never used
  src\App.vue:16:8
  import VueAwesomeSwiper from 'vue-awesome-swiper';
          ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:16:50
  import VueAwesomeSwiper from 'vue-awesome-swiper';
                                                    ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:17:36
  import 'swiper/dist/css/swiper.css';//这里注意具体看使用的版本是否需要引入样式,以及具体位置。
                                      ^

  ✘  http://eslint.org/docs/rules/spaced-comment           Expected space or tab after '//' in comment
  src\App.vue:17:37
  import 'swiper/dist/css/swiper.css';//这里注意具体看使用的版本是否需要引入样式,以及具体位置。
                                       ^

  ✘  http://eslint.org/docs/rules/no-multiple-empty-lines  More than 1 blank line not allowed
  src\App.vue:18:1

   ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:20:47
  import AppHead from '@/components/public/Head';
                                                 ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:21:47
  import AppMenu from '@/components/public/Menu';
                                                 ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:22:45
  import AppNav from '@/components/public/Nav';
                                               ^

  ✘  http://eslint.org/docs/rules/semi                     Extra semicolon
  src\App.vue:23:47
  import AppFoot from '@/components/public/Foot';
                                                 ^


✘ 9 problems (9 errors, 0 warnings)


Errors:
  6  http://eslint.org/docs/rules/semi
  1  http://eslint.org/docs/rules/no-multiple-empty-lines
  1  http://eslint.org/docs/rules/spaced-comment
  1  http://eslint.org/docs/rules/no-unused-vars


  ✘  http://eslint.org/docs/rules/semi            Extra semicolon
  src\components\Select.vue:40:36
  import 'swiper/dist/css/swiper.css';这里注意具体看使用的版本是否需要引入样式,以及具体位置。
                                      ^

  ✘  http://eslint.org/docs/rules/spaced-comment  Expected space or tab after '///' in comment
  src\components\Select.vue:40:37
  import 'swiper/dist/css/swiper.css';这里注意具体看使用的版本是否需要引入样式,以及具体位置。
                                       ^

  ✘  http://eslint.org/docs/rules/semi            Extra semicolon
  src\components\Select.vue:41:57
  import { swiper, swiperSlide } from 'vue-awesome-swiper';
                                                           ^

  ✘  http://eslint.org/docs/rules/semi            Extra semicolon
  src\components\Select.vue:43:58
  import { mapState, mapMutations, mapActions } from 'vuex';
                                                            ^


✘ 4 problems (4 errors, 0 warnings)


Errors:
  3  http://eslint.org/docs/rules/semi
  1  http://eslint.org/docs/rules/spaced-comment

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.

经过百度查询,原来eslint是一个语法检查工具,但是限制很严格,在我的vue文件里面很多空格都会导致红线(红线可以关闭提示),虽然可以关闭,但是在编译的时候老是会跳出来,所以能关闭是最好的了。
关闭方法:在build/webpack.base.conf.js文件中,注释或者删除掉:module->rules中有关eslint的规则:

module: {
  rules: [
    //...(config.dev.useEslint ? [createLintingRule()] : []), // 注释或者删除
    {
      test: /\.vue$/,
      loader: 'vue-loader',
      options: vueLoaderConfig
    },
    ...
    }
  ]
}

然后再重新运行一下npm run dev或者构建命令 npm run build就可以啦。

Logo

前往低代码交流专区

更多推荐