💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
## 一、概述 路由器对象,它来管理路由; ## 二、构建选项 routes,参考route的定义部分:[route](route.md) 更多的参考:[https://router.vuejs.org/zh/api/#router-构建选项](https://router.vuejs.org/zh/api/#router-构建选项) ## 三、实例属性 1、router.app 类型: Vue instance 配置了 router 的 Vue 根实例。 2、router.mode 类型: string 路由使用的模式。 3、router.currentRoute 类型: Route 当前路由对应的路由信息对象。 ## 四、实例方法 1、增加全局导航守卫; router.beforeEach router.beforeResolve router.afterEach 函数签名: ~~~ router.beforeEach((to, from, next) => { /* 必须调用 `next` */ }) router.beforeResolve((to, from, next) => { /* 必须调用 `next` */ }) router.afterEach((to, from) => {}) ~~~ 2、动态的导航到一个新 URL router.push router.replace router.go router.back router.forward 函数签名: ~~~ router.push(location, onComplete?, onAbort?) router.push(location).then(onComplete).catch(onAbort) router.replace(location, onComplete?, onAbort?) router.replace(location).then(onComplete).catch(onAbort) router.go(n) router.back() router.forward() ~~~ 3、动态添加更多的路由规则 router.addRoutes 函数签名: ~~~ router.addRoutes(routes: Array<RouteConfig>) ~~~ 动态添加更多的路由规则。参数必须是一个符合 routes 选项要求的数组。 更多的参考:[https://router.vuejs.org/zh/api/#router-实例方法](https://router.vuejs.org/zh/api/#router-实例方法)