Vue-router源码中history类是如何实现路由跳转的?
- 内容介绍
- 文章标签
- 相关推荐
本文共计909个文字,预计阅读时间需要4分钟。
当前版本:3.0.3目录:src/history/base.js前言:关于vue-router,它支持三种路由模式:history、hash、abstract。其中,abstract是运行在没有window的环境下的,这三种模式都继承自history类,history实现了以下功能:
当前版本: 3.0.3
类目录: src/history/base.js
前言:
对于vue-router来说,有三种路由模式history,hash,abstract, abstract是运行在没有window的环境下的,这三种模式都是继承于history类,history实现了一些共用的方法,对于一开始看vue-router源码来说,可以从这里开始看起。
初始属性
router: Router; 表示VueRouter实例。实例化History类时的第一个参数 base: string; 表示基路径。会用normalizeBase进行规范化。实例化History类时的第二个参数。 current: Route; 表示当前路由(route)。 pending: ?Route; 描述阻塞状态。 cb: (r: Route) => void; 监听时的回调函数。 ready: boolean; 描述就绪状态。 readyCbs: Array<Function>; 就绪状态的回调数组。 readyErrorCbs: Array<Function>; 就绪时产生错误的回调数组。
本文共计909个文字,预计阅读时间需要4分钟。
当前版本:3.0.3目录:src/history/base.js前言:关于vue-router,它支持三种路由模式:history、hash、abstract。其中,abstract是运行在没有window的环境下的,这三种模式都继承自history类,history实现了以下功能:
当前版本: 3.0.3
类目录: src/history/base.js
前言:
对于vue-router来说,有三种路由模式history,hash,abstract, abstract是运行在没有window的环境下的,这三种模式都是继承于history类,history实现了一些共用的方法,对于一开始看vue-router源码来说,可以从这里开始看起。
初始属性
router: Router; 表示VueRouter实例。实例化History类时的第一个参数 base: string; 表示基路径。会用normalizeBase进行规范化。实例化History类时的第二个参数。 current: Route; 表示当前路由(route)。 pending: ?Route; 描述阻塞状态。 cb: (r: Route) => void; 监听时的回调函数。 ready: boolean; 描述就绪状态。 readyCbs: Array<Function>; 就绪状态的回调数组。 readyErrorCbs: Array<Function>; 就绪时产生错误的回调数组。

