vue+ts $refs 问题

问题:
this.$refs.districtMap.previewHotel(this.newHotel)

报错:
Property 'previewHotel' does not exist on type 'Element | Element[] | Vue | Vue[]'.
Property 'previewHotel' does not exist on type 'Element'.

解决:
(this.$refs.districtMap as Vue & {previewHotel:Function}).previewHotel(this.newHotel)

原因:
TS类型

posted @ 2021-12-23 11:08  vera-7c  阅读(481)  评论(0编辑  收藏  举报