Router
Router Frontend router via popstate and pushstate.
Author: treelitec.xinle@gmail.com, Firedefirede@firede.us
router ⏏
router.pathPattern(url) ⇒ Object
Find registered path pattern by url
Kind: static method of router
Returns: Object
- The handler object associated with the given url
Param | Type | Description |
---|---|---|
url | string |
The url string |
router.reset(url, query, options)
重置当前的URL
Kind: static method of router
Access: public
Param | Type | Description |
---|---|---|
url | string |
路径 |
query | Object |
查询条件 |
options | Object |
选项 |
options.silent | boolean |
是否静默重置,静默重置只重置URL,不加载action |
router.config(options)
设置配置信息
Kind: static method of router
Access: public
Param | Type | Description |
---|---|---|
options | Object |
配置信息 |
options.path | string |
默认路径 |
options.index | string |
index文件名称 |
options.mode | string |
路由模式,可选async、page,默认为async |
router.add(path, fn, thisArg)
添加路由规则
Kind: static method of router
Access: public
Param | Type | Description |
---|---|---|
path | string | RegExp |
路径 |
fn | function |
路由处理函数 |
thisArg | Object |
路由处理函数的this指针 |
router.remove(path)
删除路由规则
Kind: static method of router
Access: public
Param | Type | Description |
---|---|---|
path | string |
路径 |
router.exist(path) ⇒ boolean
测试路由规则存在性
Kind: static method of router
Returns: boolean
- 是否存在
Access: public
Param | Type | Description |
---|---|---|
path | string |
路径 |
router.clear()
清除所有路由规则
Kind: static method of router
Access: public
router.redirect(url, query, options)
URL跳转
Kind: static method of router
Access: public
Param | Type | Description |
---|---|---|
url | string |
路径 |
query | Object |
查询条件 |
options | Object |
跳转参数 |
options.title | string |
跳转后页面的title |
options.force | boolean |
是否强制跳转 |
options.silent | boolean |
是否静默跳转(不改变URL) |
router.start(options)
启动路由监控
Kind: static method of router
Access: public
Param | Type | Description |
---|---|---|
options | Object |
配置项 |
router.stop()
停止路由监控
Kind: static method of router
Access: public
router.controller(implement)
更换控制器 仅用于单元测试及自定义控制器的调试 TODO: re-implement this via DI
Kind: static method of router
Access: public
Param | Type | Description |
---|---|---|
implement | Object |
路由控制器 |
router.getState() ⇒ Object
获取当前状态
Kind: static method of router
Returns: Object
- 返回上一次调度后的状态