uni-app 使用vscode開(kāi)發(fā)點(diǎn)擊模版中的方法、變量跳轉(zhuǎn)到指定配置

項(xiàng)目時(shí)vue2版本
1.安裝插件vetur
2.在vscdoe 設(shè)置文件中配置

{
  "editor.formatOnSave": true,
  "editor.tabSize": 2,
  // 關(guān)閉 Volar,防止沖突
  "volar.takeOverMode": false,
  // Vetur 設(shè)置
  "vetur.useWorkspaceDependencies": true,
  "vetur.experimental.templateInterpolationService": true,
  "vetur.validation.template": false,
  "typescript.validate.enable": false,
  "javascript.validate.enable": false,
  // uni-app 設(shè)置
  "uni-app": {
    "useUniApp": true
  },
  "files.associations": {
    "*.vue": "vue"
  }
}
image.png

配置后發(fā)現(xiàn)還不生效
下一步
項(xiàng)目根目錄創(chuàng)建jsconfig.json文件

{
  "compilerOptions": {
    "target": "es2017",
    "module": "esnext",
    "baseUrl": "./",
    "paths": {
      "@/*": ["*"]
    },
    "types": ["vue/types/vue"],
    "checkJs": false,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "skipLibCheck": true
  },
  "exclude": ["node_modules", "dist"]
}
image.png

此時(shí)已經(jīng)點(diǎn)擊可以跳轉(zhuǎn)到定義位置了。但是全局寫(xiě)的方法發(fā)現(xiàn)編輯器顯示紅線(xiàn)。


image.png

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)
解決:查看插件設(shè)置 取消勾選


image.png
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容