1.在 VSCode 中安装 prettier 插件(搜索 prettier),这个插件可以帮助我们在配置 prettier 的时候获得提示
2.在项目中新建 .prettierrc 文件,该文件为 perttier 默认配置文件
![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/aee39b0d61954eb2828f22204ce531f7.png
文件里面输入 (还有很多配置,可以去perttier查询进行配置)
{
// 不尾随分号
“semi”: false,
// 使用单引号
“singleQuote”: true,
// 多行逗号分割的语法中,最后一行不加逗号
“trailingComma”: “none”,
“printWidth”: 150 最大长度
}
3.vscode设置
在设置中,搜索 save ,勾选 Format On Save