代码拉取完成,页面将自动刷新
yarn create @vitejs/app
yarn add sass -D
.editorconfig
,配合插件EditorConfig VS Code
yarn add prettier -D
,添加.prettierrc
,配合插件Prettier - Code formatter
yarn add eslint -D
,然后运行 npx eslint --init
,如何失败则npm i @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-config-airbnb-base eslint-plugin-import eslint-plugin-vue -D
,配置.eslintrc.js
,配合插件EsLint
,此时.eslintrc.js 文件如下:module.exports = {
env: {
browser: true,
es2021: true,
node: true
},
extends: ['plugin:vue/essential', 'airbnb-base'],
parserOptions: {
ecmaVersion: 12,
parser: '@typescript-eslint/parser',
sourceType: 'module'
},
plugins: ['vue', '@typescript-eslint'],
rules: {}
}
yarn add eslint-plugin-prettier eslint-config-prettier -D
,在.eslintrc.js 添加配置如下:module.exports = {
...
extends: [
'plugin:vue/essential',
'airbnb-base',
'plugin:prettier/recommended' // 添加 prettier 插件
],
...
}
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'vue/no-multiple-template-root': 'off',
semi: [2, 'never'],
},
:class="$style.msg"
的写法,<style module>
vite-plugin-compression
gzipimport viteCompression from 'vite-plugin-compression'
plugins:[
...
// gzip压缩
viteCompression({
//生成压缩包gz
verbose: true,
disable: false,
threshold: 10240,
algorithm: 'gzip',
ext: '.gz',
}),
]
yarn add vite-plugin-components -D
,按需导入element-plus组件,yarn add element-plus
,在vite.config.js中配置他们,vite-plugin-style-import貌似不怎么好用?This template should help get you started developing with Vue 3 and Typescript in Vite.
.vue
Imports in TSSince TypeScript cannot handle type information for .vue
imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in .vue
imports (for example to get props validation when using manual h(...)
calls), you can enable Volar's .vue
type support plugin by running Volar: Switch TS Plugin on/off
from VSCode command palette.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。