Mui页面间的参数传值 您所在的位置:网站首页 mui框架登录页面 Mui页面间的参数传值

Mui页面间的参数传值

2024-04-03 02:49| 来源: 网络整理| 查看: 265

案例:登录页面跳转到主页面

login.html

function login() { let username = document.getElementById("username").value let password = document.getElementById("password").value let url = "http://192.168.12.56:8080/user/login" let user = { username: username, password: password } mui.ajax(url, { data: user, type: 'post', success: function(data) { if (data.code == 0) { mui.toast('登陆成功', { duration: 'short', type: 'div' }) gotohome() } else { mui.alert(data.msg) } }, error: function(xhr, type, errorThrown) { //获取本地数据 mui.toast("数据异常"); } }); }

传两个参数:

function gotohome(){ mui.openWindow({ url:"home.html", id:"home", extras:{ name:'李明', age:"20" } }) }

home.html

接受参数

mui.plusReady(function(){ let self = plus.webview.currentWebview() mui.alert(`name:${self.name};age:${self.age}`) console.log("当前页面URL:"+plus.webview.currentWebview().getURL()); });

注意点:mui.plusReady()需要在真机或模拟器环境下测试执行

显示结果:

官方给参考模板:https://dev.dcloud.net.cn/mui/window/#openwindow

mui.openWindow({ url:new-page-url, id:new-page-id, styles:{ top:newpage-top-position,//新页面顶部位置 bottom:newage-bottom-position,//新页面底部位置 width:newpage-width,//新页面宽度,默认为100% height:newpage-height,//新页面高度,默认为100% ...... }, extras:{ .....//自定义扩展参数,可以用来处理页面间传值 }, createNew:false,//是否重复创建同样id的webview,默认为false:不重复创建,直接显示 show:{ autoShow:true,//页面loaded事件发生后自动显示,默认为true aniShow:animationType,//页面显示动画,默认为”slide-in-right“; duration:animationTime//页面动画持续时间,Android平台默认100毫秒,iOS平台默认200毫秒; }, waiting:{ autoShow:true,//自动显示等待框,默认为true title:'正在加载...',//等待对话框上显示的提示内容 options:{ width:waiting-dialog-widht,//等待框背景区域宽度,默认根据内容自动计算合适宽度 height:waiting-dialog-height,//等待框背景区域高度,默认根据内容自动计算合适高度 ...... } } })


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有