大家好,
我收到这样的错误消息:
error TS2339: Property 'show' does not exist on type 'Element | Vue | Vue[] | Element[]'
它指向这样的一行:
this.$refs['myDialog'].show()
这个show
是在 TypeScript 中使用 vue-class-component 实现的方法。 它在一个扩展 Vue 的类中。 我在这里找到了 ./types/vue.d.ts 中的行。
我想它应该使用这样的泛型进行修改:
readonly $refs: { [key: string]: [V extends Vue] | Element | Array<V extends Vue> | Array<Element>};
但仅仅这样做是行不通的。
有人知道怎么做吗?
谢谢!
您要么需要转换它<YourComonent>this.$refs
或 reify $refs
。
https://github.com/HerringtonDarkholme/av-ts/wiki/FAQ#2-property-reification
你的描述不让我知道如何解决这个问题。 请逐步显示答案。
真的很困惑 ts+ vue
最有用的评论
您要么需要转换它
<YourComonent>this.$refs
或 reify$refs
。https://github.com/HerringtonDarkholme/av-ts/wiki/FAQ#2-property-reification