代码为:
import VueXxx from './src/VueXxx.vue' import Vue from 'vue' VueXxx.install = (vue: Vue) => { vue.component(VueXxx.name, VueXxx) } export default VueXxx
报错:
Property 'install' does not exist on type 'VueConstructor<Vue>'.ts(2339) Property 'component' does not exist on type 'Vue'.ts(2339)
我改成any
就不报错了:
(VueXxx as any).install = (vue: any) => { vue.component(VueXxx.name, VueXxx) }
请问,只能这么做吗?
1 troycode 2020-08-06 11:00:28 +08:00 命名不规范吧,第二个参数不能直接为 vue ? |
2 wenhai95 2020-08-06 11:13:26 +08:00 via Android 1.写一个.vue 文件的.d.ts 声明文件,在上面加一个 install 方法 2.类型标注改为 typeof Vue |