我知道这似乎是一个重复的问题,我在尝试以下后仍然会遇到这种类型的eslint错误:
这是我的package.json设置的一部分:
"devDependencies": {
"@vue/cli-plugin-babel": "^3.0.5",
"@vue/cli-plugin-eslint": "^3.0.5",
"@vue/cli-plugin-unit-jest": "^3.0.5",
"@vue/cli-service": "^3.0.5",
"@vue/eslint-config-airbnb": "^4.0.0",
"@vue/test-utils": "^1.0.0-beta.20",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0",
"eslint": "^5.8.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-vue": "^5.0.0-0",
"vue-template-compiler": "^2.5.17"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"@vue/airbnb"
],
"rules": {},
"parserOptions": {
"parser": "babel-eslint",
"ecmaVersion": 6
}
},
这是我的.eslintrc.js
文件:
module.exports = {
parserOptions: {
sourceType: 'module',
allowImportExportEverywhere: true,
},
rules: {
'no-console': 0,
},
plugins: ['vue'],
};
这是一个eslint错误的详细版本:
error: Parsing error: Unexpected token < at src/App.vue:1:1:
> 1 | <template>
| ^
2 | <div id="app">
3 | <router-view/>
4 | </div>
这是我的App.vue源代码:
<template>
<div id="app">
<router-view/>
</div>
</template>
<script>
export default {
name: 'BuilderApp',
data() {
return {
dragEvents: ['drag', 'dragstart', 'dragend', 'dragover', 'dragenter', 'dragleave', 'drop'],
};
},
mounted() {
// prevent default action for all defined dragEvents
if (this.dragAndDropCapable()) {
this.dragEvents.forEach((dragEvent) => {
document.getElementById('app').addEventListener(dragEvent, (e) => {
e.preventDefault();
e.stopPropagation();
}, false);
});
}
},
methods: {
dragAndDropCapable() {
const testDiv = document.createElement('div');
return (('draggable' in testDiv)
|| ('ondragstart' in testDiv && 'ondrop' in testDiv))
&& 'FormData' in window
&& 'FileReader' in window;
},
},
};
</script>
<style>
.filter-disable .filter-count {
background: #dadada;
}
</style>
我不确定我错过了什么。感谢您的时间和帮助!