教程:【前端开发】Vue3『路由权限』前后端全解析(1)【Vue基本功】
- vite
- pinia
- vue-router
- axios
// client\vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// 需要安装 `@type/node`
import { resolve } from 'path'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
resolve: {
alias: { '@': resolve(__dirname, 'src') },
},
})
// client\tsconfig.json
{
"compilerOptions": {
// ...
"baseUrl": ".",
"paths": { "@/*": ["./src/*"] }
},
// ...
}
// client\vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
const PORT = 9491
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
resolve: {
alias: { '@': resolve(__dirname, 'src') },
},
server: {
proxy: {
'/api': {
target: `http://localhost${PORT}`,
changeOrigin: true,
rewrite: (path: string) => path.replace(/^\/api/, ''),
},
},
},
})
- express
- typescript
- ts-node-dev