小编Aji*_*mar的帖子

解析错误:在 JavaScript 类中声明私有成员时出现意外字符“#”

当使用“#”在 javascript 类中声明私有成员时,eslint 会抛出错误Parsing error: Unexpected character '#'

例如。

class Test{
  #priavteMember; //Parsing error: Unexpected character '#'
}
Run Code Online (Sandbox Code Playgroud)

eslint配置:.eslintrc.json

{
    "env": {
        "browser": true,
        "es2021": true,
        "node": true
    },
    "extends": [
        "airbnb-base"
    ],
    "rules": {
        "no-use-before-define": "off",
        "no-param-reassign": "off",
        "no-plusplus": "off",
        "no-nested-ternary": "off",
        "lines-between-class-members": "off"
    },
    "globals": {
        "root": "readonly",
        "app": "readonly",
        "db": "readonly"
    }
}
Run Code Online (Sandbox Code Playgroud)

javascript eslint

6
推荐指数
2
解决办法
7583
查看次数

标签 统计

eslint ×1

javascript ×1