[英]Access vue component getter in tupescript mixin error (TS2339)
i have this:我有这个:
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'];
...
}
}
then然后
export default class MyModal extends MyMixin {
get activeTab(): string {
return myStore.activeTab;
}
}
Mixin calls component's getter and everything works fine, but i get this message TS2339: Property activeTab
does not exist on type 'MyMixin'. Mixin 调用组件的 getter 并且一切正常,但我收到此消息 TS2339:“MyMixin”类型上不存在属性
activeTab
。
Try defining it here尝试在这里定义它
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'];
...
}
}
It is a poor solution, but i'm not able to find another.这是一个糟糕的解决方案,但我无法找到另一个。 Casted this to any before method call.
将此转换为任何之前的方法调用。
let scrollingWrapper: any = (this.$refs[(this as any).activeTab] as Vue).$refs['scrolling-wrapper'];
Thanks to everyone.谢谢大家。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.