【问题标题】:Access getters inside the Vue Class Component decorator在 Vue 类组件装饰器中访问 getter
【发布时间】:2021-02-07 11:25:25
【问题描述】:

在我的项目中升级 ESLint 和其他包后,我的一些组件开始出现以下错误:

'InsertClassNameHere' was used before it was defined

问题是我需要从 @Component 装饰器下面的类内部访问 getter。这仅在我像这样在 Component 装饰器上显式设置类型时才有效:

@Component<InsertClassNameHere>

升级后由于 ESLint 错误,它不再工作。

当我从 @Component 装饰器中删除类名引用时,getter 不再可访问:

你知道我怎样才能引用装饰器下面的类名或访问组件的getter而不引用它吗?

【问题讨论】:

    标签: typescript vue.js eslint


    【解决方案1】:

    这可能是由于 ESLint 规则no-use-before-define。您的代码似乎依赖于在定义之前访问 hoisted 标识符。因此,最好为您的 SFC 完全禁用该规则。

    【讨论】:

      猜你喜欢
      • 2021-01-31
      • 2020-05-04
      • 1970-01-01
      • 2011-06-26
      • 2019-08-07
      • 1970-01-01
      • 2014-02-08
      • 2021-12-04
      • 1970-01-01
      相关资源
      最近更新 更多