vue中shift+alt+f格式化防止格式掉其它内容

好处就是使得提交记录干净,否则修改一两行代码,习惯性按了一下格式化快捷键,遍地飘红,下次找修改就费时间

1.点击设置图标-设置

2.点击这个转成配置文件

复制代码
{
    "extensions.ignoreRecommendations": true,
    "[vue]": {
        "editor.defaultFormatter": "octref.vetur"
    },
    "editor.fontSize": 13,
    "editor.codeActionsOnSave": {},
    "prettier.endOfLine": "crlf",
    "vetur.format.defaultFormatterOptions": {
        "js-beautify-html": {
            // #vue组件中html代码格式化样式
            "wrap_attributes": "force-aligned", //也可以设置为"auto",效果会不一样
            "wrap_line_length": 200,
            "end_with_newline": false,
            "semi": true,
            "singleQuote": true
        },
        "prettier": {
            //设置分号
            "semi": true,
            //双引号变成单引号
            "singleQuote": false,
            //禁止随时添加逗号,这个很重要。找了好久
            "trailingComma": "none",
            // 单个参数的箭头函数不加括号 x => x
            "arrowParens": "avoid",
        }
    },
    "explorer.confirmDelete": false,
    "window.zoomLevel": 1,
    "editor.formatOnSaveMode": "modificationsIfAvailable"
}
  • 末尾不加逗号
  • 箭头函数不要自己加括号
  • template不要随便改变换行

3.设置vscode的默认格式化工具为Vetur

相关推荐
ze_juejin1 分钟前
Angular的懒加载由浅入深
前端
JSON_L2 分钟前
Vue 详情模块 4
前端·javascript·vue.js
码间舞8 分钟前
什么是Tearing?为什么React的并发渲染可能会有Tearing?
前端·react.js
gnip20 分钟前
做个交通信号灯特效
前端·javascript
小小小小宇20 分钟前
Webpack optimization
前端
尝尝你的优乐美22 分钟前
前端查缺补漏系列(二)JS数组及其扩展
前端·javascript·面试
咕噜签名分发可爱多24 分钟前
苹果iOS应用ipa文件安装之前?为什么需要签名?不签名能用么?
前端
她说人狗殊途39 分钟前
Ajax笔记
前端·笔记·ajax
yqcoder1 小时前
33. css 如何实现一条 0.5 像素的线
前端·css
excel1 小时前
Nuxt 3 + PWA 通知完整实现指南(Web Push)
前端·后端