页面操作全部采用调用函数方法实现(包括监听事件)

来源:互联网 发布:中广核软件人员工资 编辑:程序博客网 时间:2024/06/05 23:56
mui.plusReady(function() {//改变statusbarplus.navigator.setStatusBarBackground('#41cea9');navtitle = document.getElementById('nav-title');mainWebView = plus.webview.currentWebview();//判断是否已经登陆,若没有登陆将预加载登陆页面,知道登陆成功为止close登陆页面judgelogin();//初始化商品详情页面。initProductDetail();//初始化页面,inittabitemWebviews();//为每个bar-item添加点击事件addEventForTabitem();//接收自定义的事件页面切换changeWebViewEvent();});


例如其中选项卡点击监听也用函数来实现

function addEventForTabitem() {mui('.mui-bar-tab').on('tap', '.mui-tab-item', function() {var tabitem = this;if (tabitem == curTabItem) {return;}curTabItem = tabitem;navtitle.innerText = tabitem.children[tabitem.children.length - 1].innerText;//设置将显示当前webviewshowCurWebView(tabitem.getAttribute('href'));});}