mui关于页面间传值的方法
2016-03-25 18:36
471 查看
2016/3/25 方法0:fire传值 mui.openWindow({ url:'road_lineWindCar.html', id:'road_lineWindCar.html', waiting:{ autoShow:false }, extras:{ car:this.getAttribute("car"), //这里的值可以是你在函数体里的具体的值,我这里是把这些值写在(li)标签里的属性 hcCityName:this.getAttribute("hcCityName"), qcStoreName:this.getAttribute("qcStoreName") } }) 在预加载里写 mui.plusReady(function(){ var car = plus.webview.currentWebview().car; var hcCityName = plus.webview.currentWebview().hcCityName; var qcStoreName = plus.webview.currentWebview().qcStoreName; }) 方法1:mui实现页面间传值:fire传值 这种方法传值,有可能传不过去 第一步:要有目标页面 var roadLinePage = plus.webview.getWebviewById('choose_car.html'); 第二步:要有自定义事件 其中getQcCity就是事件 mui.fire(roadLinePage,'getQcCity',{ qcCityName:cityName, qcCityId:cityId }); 第三部:要在目标页面监听事件getQcCity window.addEventListener('getQcCity',function(event){ //获得事件参数 var id = event.detail.qcCityId;//获取传过来的值 document.getElementById("qcCity_").value=id; console.log("取车城市"+id); freshCarTable();//要执行的函数 }); 方法2: 本地存储--存储json格式的数据 localStorage.setItem(name, JSON.stringify(value)); var obj = localStorage.getItem(name); return mui.parseJSON(obj); /** * 本地存储Utils */ var localStorageUtils = { setParam: function (name, value) { if (value) { localStorage.setItem(name, JSON.stringify(value)); } }, getParam: function (name) { var obj = localStorage.getItem(name); return mui.parseJSON(obj); }, removeParam: function (key) { return localStorage.removeItem(key); } } H5+中本地存储使用-- 方法:3: 获取应用存储区中保存的键值对的个数 var foo = plus.storage.getLength(); 修改或添加键值(key-value)对数据到应用数据存储中 void plus.storage.setItem(key, value); 通过键(key)检索获取应用存储的值 var foo = plus.storage.getItem(key); 通过key值删除键值对存储的数据 void plus.storage.removeItem(key); 清除应用所有的键值对存储数据 void plus.storage.clear(); 获取键值对中指定索引值的key值 var foo = plus.storage.key(index); var keyNames=[]; var values=[]; var numKeys=plus.storage.getLength(); for(var i=0; i<numKeys; i++) { keyNames[i] = plus.storage.key(i); values[i] = plus.storage.getItem(keyNames[i]); }
相关文章推荐
- 关于如何修改UISearchBa灰色背景
- Android官方开发文档Training系列课程中文版:使用Fragment构建动态UI之Fragment创建
- Requirements 101: User Stories vs. Use Cases
- Handler原理笔记
- ggplot2快速教程Quick Introduction to ggplot2
- poj 2081 Recaman's Sequence
- Web 快速开发框架 WebBuilder 7 发布
- multidex导入至build失败问题
- lintcode: Implement Queue by Two Stacks
- uint8、double、mat2uint、imhist绘直方图w恩替藐视
- JAVA顺序表(Sequential List)操作
- Android4.42-Setting源码分析之蓝牙模块Bluetooth(下)
- 使用SOAPUI测试WEBAPI接口
- web UI技术方案备忘
- 能否在非UI线程更新界面呢?
- Hootsuite(互随社交)
- PreferenceActivity 中的 onBuildHeaders() 调用时机
- Hootsuite(互随社交)
- Hootsuite(互随社交)
- leetcode之Repeated DNA Sequences