Home > @elux/vue-taro > IRouter
IRouter interface
路由器的定义
Signature:
export interface IRouter<TStoreState extends StoreState = StoreState>
Remarks
在 CSR 中全局只有一个 Router
在 SSR 中每个客户请求都会生成一个Router
Properties
Property | Type | Description |
---|---|---|
action | RouteAction | 当前路由动作 |
initOptions | RouterInitOptions | 路由初始化时的参数,通常用于SSR时传递原生的Request和Response对象 |
location | Location | 当前路由信息 |
routeKey | string | 当前路由的唯一ID |
runtime | RouteRuntime<TStoreState> | 当前路由的相关运行信息 |
Methods
Method | Description |
---|---|
addListener(callback) | 监听路由事件 |
back(stepOrKeyOrCallback, target, refresh, overflowRedirect) | 回退指定栈中的历史记录,并跳转路由 |
computeUrl(partialLocation, action, target) | 根据部分信息计算完整Url |
findRecordByKey(key) | 用唯一key 来查找历史记录,如果没找到则返回 {overflow: true} |
findRecordByStep(delta, rootOnly) | 用回退步数 来查找历史记录,如果步数溢出则返回 {overflow: true} |
getActivePage() | 获取当前被激活显示的页面 |
getCurrentPages() | 获取当前所有CurrentPage(PageHistoryStack中的第一条) |
getDocumentHead() | 获取当前页面的DocumentHead |
getHistory(target) | 获取指定历史栈中的记录 |
getHistoryLength(target) | 获取指定历史栈的长度 |
init(initOptions, prevState) | |
push(partialLocation, target, refresh) | 在指定栈中新增一条历史记录,并跳转路由 |
relaunch(partialLocation, target, refresh) | 清空指定栈中的历史记录,并跳转路由 |
replace(partialLocation, target, refresh) | 在指定栈中替换当前历史记录,并跳转路由 |
setDocumentHead(html) | 设置当前页面的DocumentHead |