1. 程式人生 > 程式設計 >vscode中的vue專案報錯Property ‘xxx‘ does not exist on type ‘CombinedVueInstance<{ readyOnly...Vetur(2339)

vscode中的vue專案報錯Property ‘xxx‘ does not exist on type ‘CombinedVueInstance<{ readyOnly...Vetur(2339)

問題描述:

今天早上一開機,開啟專案,發現專案一片醒目的紅色,檢視報錯原因提示:

Property ‘xxxx' does not exist on type 'CombinedVueInstance<{ readyOnly: unknown; businessPrice: unknown; travelStaffInfo: any; } & Record<never,any> & Vue,object,Record<never,any>>. Vetur(2339)

vscode中的vue專案報錯Property ‘xxx‘ does not exist on type ‘CombinedVueInstance<{ readyOnly...Vetur(2339)

解決過程:

瘋狂百度,只查明該報錯與typescript相關,但是我這裡是一個純正的vue專案,也沒有開啟tslint,為啥會報這個錯誤呢?

vscode中的vue專案報錯Property ‘xxx‘ does not exist on type ‘CombinedVueInstance<{ readyOnly...Vetur(2339)

於是重點關注結尾的Vetur(2339),想來應該是與Vetur外掛相關。
禁用了Vetur相關的外掛之後,果然不報錯了。
但是Vetur外掛涉及到的東西太多了,格式化,程式碼片段,直接關閉會導致很多功能無法正常使用!
於是開始研究Vetur的配置,果然找到了玄機。

vscode中的vue專案報錯Property ‘xxx‘ does not exist on type ‘CombinedVueInstance<{ readyOnly...Vetur(2339)

vscode中的vue專案報錯Property ‘xxx‘ does not exist on type ‘CombinedVueInstance<{ readyOnly...Vetur(2339)

解決辦法:

依次點選:檔案——首選項——設定,在開啟的頁面點選,使用者——拓展——vetur

然後瘋狂下滑,找到Validation: Interpolation一欄,看到這裡有一句:

validate interpolation in <template> region using TypeScript language service

大意就是按照TypeScript 的語法規則去校驗<template>中的語句。
豁然開朗,關閉該選項即可。

至於為啥會勾選上,八成是因為vetur升級的原因吧 。

到此這篇關於vscode中的vue專案報錯Property ‘xxx‘ does not exist on type ‘CombinedVueInstance<{ readyOnly...Vetur(2339)的文章就介紹到這了,更多相關vscode vue專案報錯內容請搜尋我們以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援我們!