在使用ts的過程中發現,父元件調用子元件方法的時候
this.$refs.childThisParent .handleCommitInfo()
發現vscode報錯Property 'handleCommitInfo' does not exist on type 'Vue的情況,但是實際上運作效果完全沒問題。
主要原因是 vscode會根據聲明檔案自動進行類型推斷的,這裡沒法知道childMethod的類型
是以,如下即可
(this.$refs.childThisParent as any).chlidMethod() 或者 (this.childThisParent as any).handleCommitInfo()
調用判斷值也可以(this.childThisParent as any).canSubmit