This skill is organized to match the Vue Router official documentation structure (https://router.vuejs.org/guide/, https://router.vuejs.org/api/). When working with Vue Router:
- Identify the topic from the user's request:
- Getting started/快速开始 → examples/essentials/getting-started.md
- Dynamic route matching/动态路由匹配 → examples/essentials/dynamic-route-matching.md
- Routes matching syntax/路由匹配语法 → examples/essentials/routes-matching-syntax.md
- Named routes/命名路由 → examples/essentials/named-routes.md
- Nested routes/嵌套路由 → examples/essentials/nested-routes.md
- Programmatic navigation/编程式导航 → examples/essentials/programmatic-navigation.md
- Named views/命名视图 → examples/essentials/named-views.md
- Redirect and alias/重定向和别名 → examples/essentials/redirect-alias.md
- Passing props to route components/向路由组件传递 props → examples/essentials/passing-props.md
- Different history modes/不同的历史模式 → examples/essentials/different-history-modes.md
- Navigation guards/导航守卫 → examples/advanced/navigation-guards.md
- Route meta fields/路由元信息 → examples/advanced/route-meta-fields.md
- Data fetching/数据获取 → examples/advanced/data-fetching.md
- Composition API/组合式 API → examples/advanced/composition-api.md
- RouterView slot/RouterView 插槽 → examples/advanced/routerview-slot.md
- Transitions/过渡效果 → examples/advanced/transitions.md
- Scroll behavior/滚动行为 → examples/advanced/scroll-behavior.md
- Lazy loading routes/懒加载路由 → examples/advanced/lazy-loading-routes.md
- Typed routes/类型化路由 → examples/advanced/typed-routes.md
- Extending RouterLink/扩展 RouterLink → examples/advanced/extending-router-link.md
- Navigation failures/导航失败 → examples/advanced/navigation-failures.md
- Dynamic routing/动态路由 → examples/advanced/dynamic-routing.md
- Load the appropriate example file from the
examples/ directory:
Essentials (基础) - examples/essentials/:
- examples/essentials/getting-started.md - Creating a router and basic setup
- examples/essentials/dynamic-route-matching.md - Dynamic route matching with params
- examples/essentials/routes-matching-syntax.md - Route matching syntax and patterns
- examples/essentials/named-routes.md - Named routes and navigation
- examples/essentials/nested-routes.md - Nested routes and RouterView
- examples/essentials/programmatic-navigation.md - Programmatic navigation with router methods
- examples/essentials/named-views.md - Named views and multiple RouterView
- examples/essentials/redirect-alias.md - Redirects and aliases
- examples/essentials/passing-props.md - Passing props to route components
- examples/essentials/different-history-modes.md - Hash, HTML5 history, and memory modes
Advanced (高级) - examples/advanced/:
- examples/advanced/navigation-guards.md - Global, per-route, and in-component guards
- examples/advanced/route-meta-fields.md - Route meta fields and custom data
- examples/advanced/data-fetching.md - Data fetching strategies
- examples/advanced/composition-api.md - Using useRouter() and useRoute() with Composition API
- examples/advanced/routerview-slot.md - RouterView slot props
- examples/advanced/transitions.md - Route transitions and animations
- examples/advanced/scroll-behavior.md - Scroll behavior configuration
- examples/advanced/lazy-loading-routes.md - Lazy loading routes and code splitting
- examples/advanced/typed-routes.md - TypeScript typed routes
- examples/advanced/extending-router-link.md - Extending RouterLink component
- examples/advanced/navigation-failures.md - Handling navigation failures
- examples/advanced/dynamic-routing.md - Adding and removing routes dynamically
- Follow the specific instructions in that example file for syntax, structure, and best practices
Important Notes:
- All examples follow Vue Router 4 API
- Examples include both JavaScript and TypeScript versions where applicable
- Each example file includes key concepts, code examples, and key points
- Always check the example file for best practices and common patterns
- Reference API documentation in the
api/ directory when needed:
- api/router.md - Router instance API (createRouter, addRoute, removeRoute, etc.)
- api/route-records.md - Route record types and properties
- api/useRouter-useRoute.md - Composition API functions (useRouter, useRoute)
- api/navigation-helpers.md - Navigation helper functions
- api/router-link-router-view-components.md - RouterLink and RouterView components
- api/history-modes-api.md - History mode APIs
- api/error-and-failure-types.md - Error and failure types
- Use templates from the
templates/ directory:
- templates/router-setup.md - Router setup templates
- templates/route-config.md - Route configuration templates