1. 安装 prettier 库
npm i -D prettier
2. 配置 package.json
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,vue,scss,css}\""
3. 根目录下放这两个文件
.prettierrc
{"semi": true,"singleQuote": true,"tabWidth": 2,"printWidth": 120,"trailingComma": "es5","arrowParens": "always","singleAttributePerLine": false,"htmlWhitespaceSensitivity": "ignore","endOfLine": "auto"
}
.prettierignore
dist
node_modules
*.md
*.yml
*.yaml
*.json
*.lock