mui中页面之间传值

来源:互联网 发布:flashfxp mac 中文 编辑:程序博客网 时间:2024/05/23 01:57

一种是在加载跳转页面时附加参数

mui('.mui-table-view').on('tap','.mui-table-view-cell',function(){            var cell_id = this.getAttribute('id');              mui.openWindow({                id:'dynamics_detail.html',                url:'dynamics_detail.html',                extras:{                    the_id:cell_id                }            });        });

下面是在跳转后页面接收值

mui.plusReady(function() {            this_phoneNum = localStorage.getItem('phoneNum');            var self = plus.webview.currentWebview();            id = self.the_id;            sendRequest();        });

当然也有一种情况是你想返回一个值给前一个页面,可以通过触发事件来传值
例如:request_person.html要返回值给new_requesst.html

request_person.html:

    mui('.mui-table-view').on('tap','.mui-table-view-cell',function(){                var id = this.getAttribute('id');                var new_request = plus.webview.getWebviewById('new_request.html');                mui.fire(new_request,'requestPerson',{id:id});                mui.openWindow({                    id:'new_request.html',                })            })

new_request.html:

window.addEventListener('requestPerson',function(event){                //获得事件参数                var id = event.detail.id;                requestPerson = id;                document.getElementById('requestList').innerText = id;            })

当然在页面之间传值更为简单方式,就是使用web储存,将所用的值存在客户端

localStorage.setItem("name",acount);localStorage.getItem("name");
原创粉丝点击