Vite2 + Vue3 + TypeScript + Pinia 搭建后台管理系统

170 阅读1分钟

本文旨在记录本人在搭建后台管理系统过程中遇到的知识点,便于日后查询。

参考的github项目

持续更新中...

一. 项目搭建

待更新...

二. 路由配置模块

1. vue-router常用api

vue-router官方文档

  • createRouter

创建一个可以被Vue应用程序使用的路由实例。查看 RouterOptions 中的所有可以传递的属性列表。

  • createWebHashHistory

创建一个 hash 历史记录。对于没有主机的 web 应用程序 (例如 file://),或当配置服务器不能处理任意 URL 时这非常有用。注意:如果 SEO 对你很重要,你应该使用 createWebHistory

  • RouteRecordRaw

当用户通过 routes option 或者 router.addRoute() 来添加路由时,可以得到路由记录。

2. 自动导入文件 import.meta.globEager

使用 import.meta.globEager实现自动引入文件。

const metaRouters = import.meta.globEager('./modules/*.ts');
console.log('metaRouters:', metaRouters);

三. axios配置模块

1. AxiosRequestConfig

AxiosRequestConfig 详解

四. Pinia配置模块

1. Pinia

2. Pinia的创建