使用vite构建和下载
首先创建一个空文件夹
1  | yarn create vite  | 
选择构建vue项目,并为其项目根目录命名
初始化后,安装相关依赖
1  | yarn  | 
Vuex
1  | yarn add vuex  | 
vue-router
1  | yarn add vue-router  | 
axios
1  | yarn add axios  | 
sass
1  | yarn add sass sass-loader -dev  | 
element-plus
1  | yarn add element-plus  | 
文件资源管理
在src下创建views文件夹
1  | mkdir -p src/view  | 
在src下创建store/index.js文件及其相关文件
Linux:
1  | mkdir -p src/store && touch src/store/index.js && touch src/store/getters.js && touch src/store/states.js && touch src/store/mutations.js && touch src/store/actions.js  | 
windows:
1  | mkdir src\store ;  | 
在src下创建router文件夹
Linux:
1  | mkdir -p src/router && touch src/router/index.js  | 
windows:
1  | mkdir src\router ; cd . > src\router\index.js  | 
在src下创建http文件
Linux:
1  | mkdir -p src/http && touch src/http/index.js  | 
windows:
1  | mkdir src\http ; cd . > src\http\index.js  | 
在src下创建styles文件夹并且创建variables.scss文件
Linux:
1  | mkdir -p src/styles && touch src/styles/variable.scss  | 
windows:
1  | mkdir src\styles ; cd . > src\styles\variable.scss  | 
通用工具函数(utils)和共享代码(shared)文件夹
Linux:
1  | mkdir -p src/utils && mkdir -p src/shared  | 
windows:
1  | mkdir src\utils ; mkdir src\shared  | 
创建jsconfig.json或tsconfig.json给开发工具读,放在根目录下
Linux:
1  | touch jsconfig.json  | 
windows:
1  | cd . > jsconfig.json  | 
1  | {  | 
挂载和配置
1  | import {defineConfig} from 'vite'  | 
1  | import axios from "axios";  | 
1  | import {createRouter, createWebHistory} from "vue-router";  | 
1  | import Vuex from 'vuex'  | 
1  | export default {  | 
1  | export default {  | 
1  | import httptool from "../http";  | 
你可能会多使用modules多套一层,但是自己手动加了
最终挂载
1  | import { createApp } from 'vue'  | 
一些准则
个人文件资源设计代码风格的一些设定
utils 文件夹通常用于存放与功能无关的通用工具函数,比如日期处理、字符串处理、HTTP 请求等。这些函数可以被项目中的多个组件或模块共享使用。
shared 文件夹通常用于存放与项目特定功能相关的共享代码,比如自定义的表单验证规则、数据处理逻辑等。这些代码在整个项目中需要重复使用,并且与项目的特定功能紧密相关。
assets一般静态资源文件的存储位置
static 打包之后assets会被处理到static有压缩的,如果不想被处理,可以先放在这里