vscode设置vue属性多了格式化不换行

4,322 阅读1分钟

问题描述:

vue有很多属性的时候,vscode格式化会自动换行,每个属性占一行,看起来很难受

解决方法:

首先打开vscode的 》文件 》 首选项 》设置

搜索vetur.format.defaultFormatter.html ,下面有个下拉框,选择js-beautify-html (PS:需要你先安装这个插件)

点击左侧三个点 选择打开setting.json,加入如下代码,然后保存

"vetur.format.defaultFormatterOptions": {
"js-beautify-html": {
"wrap_attributes": "auto" 
},
"prettyhtml": {
"printWidth": 100,
"singleQuote": false,
"wrapAttributes": false,
"sortAttributes": false
}
}