zoukankan      html  css  js  c++  java
  • Mui页面间的参数传值

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

    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,//新页面底部位置
          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:{
            waiting-dialog-widht,//等待框背景区域宽度,默认根据内容自动计算合适宽度
            height:waiting-dialog-height,//等待框背景区域高度,默认根据内容自动计算合适高度
            ......
          }
        }
    })
  • 相关阅读:
    编译nginx增加fair模块
    使用CentOS8来部署php7.4
    通过PHP代码将大量数据插入到Sqlite3
    不同程序语言处理加密算法的性能对比(PHP/Golang/NodeJS)
    CentOS8更换国内YUM源
    MySQL获取上月第一天、上月最后日、本月第一天、本月最后日的方法
    GO
    Go-数据类型以及变量,常量,函数,包的使用
    GO语言介绍以及开发环境配置
    利用python代码操作git
  • 原文地址:https://www.cnblogs.com/tdyang/p/13434478.html
Copyright © 2011-2022 走看看