Vue.js:typescript不';无法识别组件中的mixin数据

Vue.js:typescript不';无法识别组件中的mixin数据,typescript,vue.js,Typescript,Vue.js,我到处找了找,但真的找不到答案 我从Typescript中得到一个错误,该属性不存在,而它实际上存在于组件中包含的mixin中 MyMixin.ts import Vue from 'vue'; export const myMixin = Vue.mixin({ computed: { someComputedData: function() { return 'This is my computed data'; } } }); MyComponen

我到处找了找,但真的找不到答案

我从Typescript中得到一个错误,该属性不存在,而它实际上存在于组件中包含的mixin中

MyMixin.ts

import Vue from 'vue';

export const myMixin = Vue.mixin({
  computed: {
    someComputedData: function() {
       return 'This is my computed data';
    }
  }
});
MyComponent.vue

import Vue from 'vue';
import { myMixin } from '../mixins/MyMixin';

export default Vue.extend({
  name: 'MyComponent',
  mixins: [myMixin],
  methods: {
    someMethod: function() {
      this.someComputedData // <<< Typescript complains that this property doesn't exist
    }
  }
});
从“Vue”导入Vue;
从“../mixins/myMixin”导入{myMixin};
导出默认Vue.extend({
名称:“MyComponent”,
mixin:[myMixin],
方法:{
someMethod:function(){

这个.someComputedData//
mixin
vue TypesScript
中不太受支持,因为
vue类组件
依赖性。我曾经尝试过这个,但没有成功。是的,我尝试过
vue mixin decorator
vue typedMixin
,没有运气。显然,mixin和typescript只在类中工作组件。我不使用类组件的原因是因为在Vue 3中,他们会放弃类组件而使用功能组件。因为您正在为Vue 3做准备,所以最好完全避免混入并使用组合API。
mixin
Vue TypesScript
中不太支持,因为
Vue类组件Nt
依赖项。我曾经尝试过,但没有成功。是的,我尝试过
vue mixin decorator
vue typed mixins
,运气不好。显然,mixin和typescript只在类组件中工作。我之所以不使用类组件,是因为在vue 3中,它们会放弃它,转而使用功能组件。因为不管怎么说,您正在为VUE3做准备,最好完全避免混入并使用CompositionAPI。