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,//等待框背景区域高度,默认根据内容自动计算合适高度
            ......
          }
        }
    })
  • 相关阅读:
    js学习(三)对象与事件
    js学习(二)
    js学习(一)
    SSM+Redis结构框架及概述
    javaBean、EJB、POJO
    flex布局时的居中问题
    layui后台管理系统的坑
    基于element的模糊查询
    vue数组的运用
    uni-app 图片上传(uploadFile)
  • 原文地址:https://www.cnblogs.com/tdyang/p/13434478.html
Copyright © 2011-2022 走看看