xtraderClient/docs/core/router.md
2026-02-14 18:59:36 +08:00

31 lines
741 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# router/index.ts
**路径**`src/router/index.ts`
## 功能用途
Vue Router 配置,定义路由表与滚动行为。
## 路由表
| path | name | component |
|------|------|-----------|
| / | home | Home |
| /trade | trade | Trade |
| /login | login | Login |
| /trade-detail/:id | trade-detail | TradeDetail |
| /event/:id/markets | event-markets | EventMarkets |
| /wallet | wallet | Wallet |
## 滚动行为
-`savedPosition` 且来自已命名路由:恢复位置
-`to.hash`:滚动到锚点
- 否则:滚动到顶部
## 扩展方式
1. **路由守卫**`beforeEach` 做鉴权、重定向
2. **懒加载**`component: () => import('./views/Home.vue')`
3. **meta**:为路由增加 `meta.requiresAuth`