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

相关推荐
小奶包他干奶奶8 小时前
Webpack学习——Loader(文件转换器)
前端·学习·webpack
zy happy9 小时前
若依 vue3 报错:找不到模块“@/api/xxxx/xxxxx”或其相应的类型声明。。Vue 3 can not find mod
前端·javascript·vue.js
潘小安9 小时前
Git Worktree + Claude Code:让你的开发效率翻倍的秘密武器
前端
meichaoWen9 小时前
【Vue3】vue3的全面学习(一)
前端·javascript·学习
小猪努力学前端10 小时前
在 React + React Router v7 SSR 项目里做多端适配,我踩的两个坑
前端·react.js
q***d17310 小时前
React桌面应用开发
前端·react.js·前端框架
8***293110 小时前
解决 Tomcat 跨域问题 - Tomcat 配置静态文件和 Java Web 服务(Spring MVC Springboot)同时允许跨域
java·前端·spring
0***1410 小时前
React计算机视觉应用
前端·react.js·计算机视觉
Q***K5510 小时前
React高级
前端·react.js·前端框架
c***979810 小时前
React语音识别案例
前端·react.js·语音识别