[MUI] mui framework implements traditional values between pages

1: openWindow method MUI package:

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毫秒;
      event:'titleUpdate',//页面显示时机,默认为titleUpdate事件时显示
      extras:{}//窗口动画是否使用图片加速
    },
    waiting:{
      autoShow:true,//自动显示等待框,默认为true
      title:'正在加载...',//等待对话框上显示的提示内容
      options:{
        width:waiting-dialog-widht,//等待框背景区域宽度,默认根据内容自动计算合适宽度
        height:waiting-dialog-height,//等待框背景区域高度,默认根据内容自动计算合适高度
        ......
      }
    }
})

among them:

Extras: Additional extension parameters of the new window, may be used to pass values ​​between pages process; for example:

旧页面设置:
var webview = mui.openWindow({
    url:'info.html',
    extras:{
        name:'mui'  //扩展参数
    }
});

新页面:
mui.plusReady(function () {
   var self = plus.webview.currentWebview();
   // 或 var self = plus.webview.getWebviewById('new');
   console.log("extras:" + self.targetId);
})

可能的: 
console.log(webview.name);//输出mui字符串 

Note : Extended parameter is only valid when you open a new window, extras invalid parameters passed if the target window is preloaded page is opened by mui.openWindow method.

Reference: HTTP: //laopo.cnblogs.com/p/50 ...


2: HTML5 local storage: localStorage, sessionStorage

Feature detection:

    if(window.sessionStorage){
        // OK
    }else{
        // FAIL
    }

Reference: HTTP: //www.cnblogs.com/firstF ...


3: Using URL parameter passing

When the page jump add parameters provided window.location.href, page window.location.search reception parameters acquired by the parameter string.

  • Send parameters page:

window.location.href = 'new.html?targetId=123'
  • Receiving a page parameter:

// 获取url中的参数
function getUrlParam (name) {
     var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
     var r = window.location.search.substr(1).match(reg);
     if (r!= null) {
        return unescape(r[2]);
     }else{
        return null;
     }
}    
//获取url中的targetId参数
var targetId = getUrlParam('targetId');
console.log(targetId);

4: Other References:

This article addresses: HTTPS: //segmentfault.com/a/11 ...

Guess you like

Origin www.cnblogs.com/homehtml/p/12500827.html