mui中页面之间传值

本文介绍了在移动端应用中实现页面间数据传递的方法,包括通过附加参数的方式进行跳转页面时的数据传递,以及如何利用触发事件来从一个页面向另一个页面回传值。此外还提到了使用Web存储作为另一种简便的数据传递手段。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

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");
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值