Vue 扩展“Volar”未在脚本设置中格式化代码

thi*_*dzz 7 vue.js

有没有办法让 Volar 扩展在脚本设置中格式化代码?我没有使用 Vetur,因为它与 vue 3 及其新语法不够兼容。

小智 12

根据nuxt3官方文档添加volar扩展,如链接所示。(https://vuejs.org/guide/typescript/overview.html

并将以下代码添加到项目顶部的 .vscode/setting.json 中。

"[vue]": {
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "Vue.volar"
},
Run Code Online (Sandbox Code Playgroud)

如果它没有立即应用,请按 command + shift + p 键运行命令窗口,然后运行 ​​> Developer: Reload Window 命令。