创建项目
$ npm create vite@latest my-app
选择vue模板,vue-ts:
配置eslint 和 prettier
eslint是一个插件化的代码检查工具,prettier则是一个代码格式化工具。这两个工具通常被结合起来在前端项目中使用。
eslint和prettier的区别在于,eslint主要用来检测代码错误,提高代码质量,prettier则用来统一代码规范。
安装依赖:
yarn add eslint eslint-plugin-vue @typescript-eslint/parser @typescript-eslint/eslint-plugin -D
yarn add prettier eslint-config-prettier eslint-plugin-prettier -D
在项目根目录下新增.eslintrc.js文件:
module.exports = {
parser: 'vue-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', /