gpt4 book ai didi

javascript - Vue.js eslint 解析错误。 : unexpected token

转载 作者:行者123 更新时间:2023-11-30 14:44:46 25 4
gpt4 key购买 nike

我在 state.js 文件中收到此错误(在 const 配置文件中的 =>)不明白为什么...感谢反馈

const credentials = {
email: '',
password: ''
}
const profile = {
=> userId: '',
gender: '',
firstName: '',
lastName: '',
address: '',
zipCode: '',
city: '',
country: 'France',
musician: false,
musicInstruments: [],
yearsPlaying: 0
}
export default {
credentials,
profile
}

来自 vue-cli 的标准 eslint conf。网络包初始化

.eslintrc.js

// https://eslint.org/docs/user-guide/configuring

module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint'
},
env: {
browser: true,
},
extends: [
// https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
// consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
'plugin:vue/essential',
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
'standard'
],
// required to lint *.vue files
plugins: [
'vue'
],
// add your custom rules here
rules: {
// allow async-await
'generator-star-spacing': 'off',
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
}
}

错误

file: 'file:///Users/yves/Developments/WIP/FIREBASE/vue-firebase-tutorial-store-user/src/store/state.js'
severity: 'Error'
message: 'Parsing error: Unexpected token

[0m [90m 4 | [39m}[0m
[0m [90m 5 | [39m[36mconst[39m profil[0m
[0m[31m[1m>[22m[39m[90m 6 | [39m[36mexport[39m [36mdefault[39m {[0m
[0m [90m | [39m[31m[1m^[22m[39m[0m
[0m [90m 7 | [39m credentials[0m
[0m [90m 8 | [39m}[0m
[0m [90m 9 | [39m[0m'
at: '6,1'
source: 'eslint'
code: 'undefined'

最佳答案

开启 ES6:

  parserOptions: {
parser: 'babel-eslint'
},

应该是:

  parserOptions: {
parser: 'babel-eslint',
ecmaVersion: 6
},

关于javascript - Vue.js eslint 解析错误。 : unexpected token,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49129296/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com