且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何解决在Ionic Vue方法中定义嵌套范围内的`this`时出现ESLint错误

更新时间:2022-06-24 14:16:59

可以,有一个解决方案。您可以在ESlint配置文件中添加以下对象

{
  "@typescript-eslint/no-this-alias": [
    "error",
    {
      "allowDestructuring": true, // Allow `const { props, state } = this`; false by default
      "allowedNames": ["vm"] // Allow `const vm= this`; `[]` by default
    }
  ]
}

有关更多信息,请查看TSLint:no-this-assignment