首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >离子服务抱怨有效的javascript“解析错误:意外令牌=”

离子服务抱怨有效的javascript“解析错误:意外令牌=”
EN

Stack Overflow用户
提问于 2022-01-07 13:27:01
回答 1查看 139关注 0票数 0

我有一个叫做Profile.js的vuex-orm模型

代码语言:javascript
复制
import { Model } from '@vuex-orm/core'

export default class Profile extends Model {
    static entity = 'profile'

    static fields () {
        return {
            id: this.uid(),
            // etc...
        }
    }
}

当我运行ionic serve时,我得到以下输出:

代码语言:javascript
复制
Build finished at 14:20:05 by 0.000s
[INFO] Browser window opened to http://localhost:4200!
ERROR in 
[vue-cli-service] /home/user/IonicProjects/ionic/iloveu/src/store/models/Profile.js
[vue-cli-service]   4:19  error  Parsing error: Unexpected token =
[vue-cli-service] 
[vue-cli-service] ✖ 1 problem (1 error, 0 warnings)
[vue-cli-service] 
[vue-cli-service] webpack compiled with 1 error

所以它抱怨这条线

代码语言:javascript
复制
static entity = 'profile'

它是完全有效的javascript或ecmascript。

我能做什么使这个有效的代码不被标记为错误?

我的.eslintrc

代码语言:javascript
复制
module.exports = {
  root: true,
  env: {
    node: true
  },
  'extends': [
    'plugin:vue/vue3-essential',
    'prettier'
  ],
  parserOptions: {
    ecmaVersion: 2020
  },
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'vue/no-deprecated-slot-attribute': 'off'
  },
  overrides: [
    {
      files: [
        '**/__tests__/*.{j,t}s?(x)',
        '**/tests/unit/**/*.spec.{j,t}s?(x)'
      ],
      env: {
        jest: true
      }
    }
  ]
}

引用vuex-orm文档

EN

回答 1

Stack Overflow用户

发布于 2022-01-07 13:50:40

看来这就是凶手的指纹

代码语言:javascript
复制
  parserOptions: {
    ecmaVersion: 2020
  },

改到

代码语言:javascript
复制
  parserOptions: {
    ecmaVersion: 2022
  },

不再返回此错误,这很奇怪,因为类星体框架使用ecmaVersion: 2018并且没有此错误。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70621949

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档