在使用vue cli3的时候,遇到如下问题:
error: Parsing error: Unexpected token < at src\views\index.vue:1:1:
> 1 | <template>
| ^
| <div class="index">
| <router-view></router-view>
| <TabBar :data="tabbarData"></TabBar>
解决方法:
1.确认安装 eslint-plugin-vue
依赖
vue-cli (Recommended):
vue add @vue/cli-plugin-eslint
npm (opens new window):
npm install --save-dev eslint eslint-plugin-vue
yarn (opens new window):
yarn add -D eslint eslint-plugin-vue
2.在.eslint.js
配置文件中添加如下配置:
module.exports = {
root: true,
parserOptions: {
sourceType: 'module'
},
parser: "vue-eslint-parser",
env: {
browser: true,
node: true,
es6: true,
},
rules: {
'no-console': 'off',
}
}
3.重启node解决;