多页面-HASH-页面间传值 Sloth-state

Sloth-state.js

由于项目使用其他前端框架编写,没有几个页面,只需要一个页面带参数的跳转,所以就写了这个方法;不依赖任何js;

1/ Sloth.state.setConfig

设置各个页面传值和跳转的名字

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

go方法第一个参数是路由名字;第二个是传值;

Sloth.state.go('index',{id:1});

3/Sloth.state.goBack

返回上一页 Sloth.state.goBack();

4/Sloth.state.currentPage

是当前页面的路由的名字;

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();

这是一些已经实现的方法,目前够用了;

git: https://github.com/xueliangGit/Sloth-state.git

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值