属性在类型 CombinedVueInstance 上不存在

时间:2021-07-08 11:14:36

标签: typescript vue.js nuxt.js

我的打字稿编译器不会将返回的 data 类型添加到 CombinedVueInstance。我的组件:

import Vue from 'vue';

export default Vue.extend({
  data() {
    return { title: '' };
  },
  head() {
    return { title: this.title };
  },
});

在编译时(和在 Vetur 中)我得到错误 Property 'title' does not exist on type 'CombinedVueInstance<Vue, unknown, unknown, unknown, Readonly<Record<never, any>>>'.,如果我尝试在计算属性或其他地方使用 this.title,同样如此。

我正在使用在适当位置配置了 @nuxt/typescript-build 和 @nuxt/types 的 Nuxt (v2.15.7)。

0 个答案:

没有答案