因为项目使用其余前端框架编写,没有几个页面,只须要一个页面带参数的跳转,因此就写了这个方法;不依赖任何js;html
1/ Sloth.state.setConfig
前端
设置各个页面传值和跳转的名字git
Sloth.state.setConfig({ //'default' 是路由的名字,用来go方法跳转template是页面路径;链接host的绝对路径 param是传值的规格;用'/'分开
'default': {
template: 'index.html',
path: '/',
param: ''
},
'index': {
template: 'index.html',
path: '/',
param: ''
},
'foods': {
template: 'foods.html',
path: '/',
param: '/id'
})
复制代码
2/Sloth.state.go
github
go方法第一个参数是路由名字;第二个是传值;bash
Sloth.state.go('index',{id:1});
前端框架
3/Sloth.state.goBack
框架
返回上一页 Sloth.state.goBack();
ui
4/Sloth.state.currentPage
url
是当前页面的路由的名字;spa
5/Sloth.state.params
获取本页面的hash值接收到的参数 Sloth.state.params
6/Sloth.state.chang
hash值变化时调用的参数
Sloth.state.chang(function(){ //页面hash值变化时触发事件 });
复制代码
7/Sloth.state.backViewUrl
返回上一个页面的url Sloth.state.backViewUrl();
这是一些已经实现的方法,目前够用了;