用yarn已经搭建好了vue3项目项目里还需要配什么具体步骤
- 安装vue-router:yarn add vue-router@next
- 安装vuex:yarn add vuex@next
- 安装axios:yarn add axios
- 配置webpack:在webpack.config.js中配置alias,如下所示:
const path = require('path');
module.exports = {
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
};
- 配置babel:在babel.config.js中添加vue-jsx插件,如下所示:
module.exports = {
presets: [
'@babel/preset-env',
'@vue/babel-preset-app'
],
plugins: [
['@vue/babel-plugin-jsx', { transformOn: true }]
]
}
- 配置eslint:在.eslintrc.js中添加以下配置,如下所示:
module.exports = {
extends: [
'plugin:vue/vue3-essential',
'eslint:recommended',
'@vue/typescript/recommended'
],
plugins: ['@typescript-eslint'],
parserOptions: {
ecmaVersion: 2020
},
env: {
browser: true,
node: true,
},
rules: {
// add your custom rules here
}
}
- 按需加载vant组件(如需要):安装vant并按需加载组件,具体步骤可参考vant官方文档。
以上就是搭建vue3项目后需要配置的一些常用环境和插件,根据具体需求可酌情添加
原文地址: https://www.cveoy.top/t/topic/g7Ed 著作权归作者所有。请勿转载和采集!