Typescript 访问tupescript mixin错误中的vue组件获取程序(TS2339)

Typescript 访问tupescript mixin错误中的vue组件获取程序(TS2339),typescript,vue.js,vue-component,mixins,Typescript,Vue.js,Vue Component,Mixins,我有这个: import {Component, Vue} from 'vue-property-decorator'; @Component({}) export default class MyMixin extends Vue { scrollToTop(): void { let scrollingWrapper: any = (this.$refs[this.activeTab] as Vue).$refs['scrolling-wrapper'];

我有这个:

import {Component, Vue} from 'vue-property-decorator';

@Component({})
export default class MyMixin extends Vue {
scrollToTop(): void {
        let scrollingWrapper: any = (this.$refs[this.activeTab] as Vue).$refs['scrolling-wrapper'];
        ...
    }
}
然后

Mixin调用组件的getter,一切正常,但我收到一条消息TS2339:Property
activeTab
不存在于类型“MyMixin”上。

请尝试在此处定义它

import {Component, Vue} from 'vue-property-decorator';

@Component({})
export default class MyMixin extends Vue {

activeTab: any;
scrollToTop(): void {
        let scrollingWrapper: any = (this.$refs[**this.activeTab**] as Vue).$refs['scrolling-wrapper'];
        ...
    }
}

这是一个糟糕的解决方案,但我找不到另一个。将其强制转换为任何before方法调用

let scrollingWrapper: any = (this.$refs[(this as any).activeTab] as Vue).$refs['scrolling-wrapper'];

谢谢大家。

您在
MyMixin
类中定义了
activeTab
了吗?不,我没有。我正在调用它。$refs,没有其他定义。您使用的typescript版本是什么?typescript的版本是3.4.5。由于几乎没有存储区的组件,因此activeTab具有非常动态的行为,无法永久定义一次。您是否可以尝试调用
scrollingWrapper
而不是
activeTab
,可能不会,如您所见-我根据当前的activeTab定义scrollingWrapper。
let scrollingWrapper: any = (this.$refs[(this as any).activeTab] as Vue).$refs['scrolling-wrapper'];