Typescript 如何在模块扩充中引用组件选项的其他通用参数?
以下是我想在Typescript 如何在模块扩充中引用组件选项的其他通用参数?,typescript,vue.js,Typescript,Vue.js,以下是我想在.d.ts文件中执行的操作: declare module 'vue/types/options' { interface ComponentOptions<V extends Vue> { beforeInstance?: (options: ComponentOptions<V>) => void | Promise<(vm: CombinedVueInstance<V, Data, Methods, Computed, Pr
.d.ts
文件中执行的操作:
declare module 'vue/types/options' {
interface ComponentOptions<V extends Vue> {
beforeInstance?: (options: ComponentOptions<V>) => void | Promise<(vm: CombinedVueInstance<V, Data, Methods, Computed, Props>) => any | undefined>;
}
}
它将中断我的组件定义中的类型推断:
export default Vue.extend({
data: function () {
return {
value: 'abc'
};
},
mounted: function () {
console.log(this.value); // This does not work.
}
});
你找到解决办法了吗?@PhilippKühn是的,但我不记得是怎么解决的。
export default Vue.extend({
data: function () {
return {
value: 'abc'
};
},
mounted: function () {
console.log(this.value); // This does not work.
}
});