實時更新。
問題1、vetur0.31.0,無法格式化.vue文件
2020-12-10 已經發布了 0.31.1 版本(Fix Vetur can’t format),安裝新版即可(如果不會安裝插件的固定版本,請看最後)。
問題2、Vetur find tsconfig.json
/jsconfig.json
, but they aren’t in the project root.
0.31.0版本新增了一個vetur.config.js的配置文件,在這個版本之後,會優先查找項目中是否配有tsconfig.json(ts項目)或者jsconfig.json(js項目),沒找到再去找vetur.config.js,如果都沒有,就會拋出這個提示。
方案1、爲對應項目(ts/js)添加json文件
以js項目爲例,在根目錄創建jsconfig.json,添加如下代碼,詳情參考文檔
{
"include": [
"./src/*"
]
}
方案2、添加vetur.config.js
普通項目
// vetur.config.js
module.exports = {
// vetur配置,會覆蓋vscode中的設置。 default: `{}`
settings: {
"vetur.useWorkspaceDependencies": true,
"vetur.experimental.templateInterpolationService": true
},
// 普通項目採用默認配置 default: `[{ root: './' }]`
}
大型項目,可參考文檔
// vetur.config.js
module.exports = {
// vetur配置
settings: {
"vetur.useWorkspaceDependencies": true,
"vetur.experimental.templateInterpolationService": true
},
// support monorepos
projects: [
'./packages/repo2', // shorthand for only root.
{
// **required**
// Where is your project?
// It is relative to `vetur.config.js`.
root: './packages/repo1',
// **optional** default: `'package.json'`
// Where is `package.json` in the project?
// We use it to determine the version of vue.
// It is relative to root property.
package: './package.json',
// **optional**
// Where is TypeScript config file in the project?
// It is relative to root property.
tsconfig: './tsconfig.json',
// **optional** default: `'./.vscode/vetur/snippets'`
// Where is vetur custom snippets folders?
snippetFolder: './.vscode/vetur/snippets',
// **optional** default: `[]`
// Register globally Vue component glob.
// If you set it, you can get completion by that components.
// It is relative to root property.
// Notice: It won't actually do it. You need to use `require.context` or `Vue.component`
globalComponents: [
'./src/components/**/*.vue'
]
}
]
}
方案3、配置vetur插件,忽略提示
在vscode的settings.json裏面添加
vetur.ignoreProjectWarning: true
但是文檔中有寫,所以不妨添加個配置文件,也不麻煩。
If you don’t have any tsconfig.json, jsconfig.json in project, Vetur will use fallback settings. Some feature isn’t work. Like: path alias, decorator, import json.
PS:如果你需要,安裝vscode插件歷史版本的方法
找到你需要的版本