天天看點

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

轉載自:https://blog.csdn.net/SilenceJude/article/details/108400198

文章目錄

    • 問題描述:
    • 解決過程:
    • 解決辦法:

問題描述:

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

Property ‘xxxx’ does not exist on type 'CombinedVueInstance<{ readyOnly: unknown; businessPrice: unknown; travelStaffInfo: any; } & Record<never, any> & Vue, object, object, 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更新的原因吧 。

繼續閱讀