以下代码全部在script标签内
一.通过mui.openWindow()打开新页面(若目标页面为已预加载成功的页面,则在openWindow方法中传递的extras参数无效);
mui.openWindow({
url:'info.html',
id:'info.html',
extras:{ name:'mui', version:'0.5.8' }
});
接收参数:
1:
var self = plus.webview.currentWebview();
var name = self.name;
var version = self.version;
2:
mui.plusReady(function(event){
//获得参数 var name= plus.webview.currentWebview().name;var version = plus.webview.currentWebview().version;
});
二.通过事件fir
mui(".mui-table-view").on('tap','.mui-table-view-cell',function(){
//获取id
var id = this.getAttribute("id"); //传值给详情页面,通知加载新数据,detail是获取的详情页面的id mui.fire(detail,'getDetail',{ id:id}); //打开新闻详情 mui.openWindow({ id:'detail', url:'detail.html' }); }) 接收参数:
window.addEventListener('getDetail',function(event){ //通过event.detail可获得传递过来的参数内容 var id = event.detail.id; }); 三.设置全局参数 var name = 'name'; var id = '10'; localStorage.setItem('$name', name);
localStorage.setItem('$id',id);
接收参数:
var name = localStorage.getItem('$name');
var id = localStorage.getItem('$id');