vue项目运行时报错整理1

vue-cli刚搭建好项目,运行时报错

1、项目下面报错
error in ./src/components/Hello.vue
Syntax Error: Unexpected token {
@ ./~/vue-style-loader!./~/css-loader?{"minimize":false,"sourceMap":false}!./~/vue-loader/lib/style-compiler?{"id":"data-v-53cf4260","scoped":true,"hasInlineConfig":false}!./~/vue-loader/lib/selector.js?type=styles&index=0!./s
rc/components/Hello.vue 4:14-313 13:3-17:5 14:22-321
@ ./src/components/Hello.vue
@ ./src/router/index.js
@ ./src/main.js
@ multi ./build/dev-client ./src/main.js

解决办法:

修改package.json:

"vue-loader": "11.1.4",
"style-loader": "^0.13.2",

2、找不到依赖,并让你安装报错如下:

This dependency was not found:

* common/stylus/index.styl in ./src/main.js

To install it, you can run : npm install --save common/stylus/index.styl

> Listening at http://localhost:8080

解决办法:其实它并不是一个node模块

build目录下的webpack.base.conf.js文件中如下设置即可

resolve: {
  extensions: ['.js', '.vue', '.json'],
  alias: {
    'vue$': 'vue/dist/vue.esm.js',
    '@': resolve('src'),
    'common': resolve('src/common')
  }
},

3、控制台报错如下:

Unknown custom element: <router-link> - did you register the component corre

解决办法:没有引入router!!!没有引入router!!!没有引入router!!!(重要事情说三遍)



猜你喜欢

转载自blog.csdn.net/liuxin_1991/article/details/78591440