- 1. md
- 2. mta 底部選項(xiàng)卡
- 3.mhe 頂部頭
- 4.mbo 內(nèi)部寫輪播圖
- 5.ms 輪播圖
- 6.mg 九宮格
- 7.mli 圖文列表
動(dòng)態(tài)操作
-
1. 綁定點(diǎn)擊事件
[事件管理文檔](http://dev.dcloud.net.cn/mui/event/#gesture)
document.getElementById("iPhone").addEventListener("tap",function(){}
-
2.提示框
mui.toast("你點(diǎn)擊了iPhone按鈕");
-
3.打開另外一個(gè)頁面 mui.openWindow
窗口管理
document.getElementById("setting").addEventListener("tap",function(){
mui.openWindow({
url:"login.html",
id:"login.html",
styles:{
top:"0px",
bottom:"50px"
}
})
})
-
4.頁面間的傳值
- 傳值頁面 extras
document.getElementById("setting").addEventListener("tap",function(){
mui.openWindow({
url:"login.html",
id:"login.html",
styles:{
top:"0px",
bottom:"50px"
},
extras:{
user_id:"hahaha",
}
})
})
- 接受值頁面
var Sdata =null;
mui.plusReady(function(){
Sdata= plus.webview.currentWebview();
mui.toast(Sdata.user_id);
})
如果想用plus就必須在plusReady下使用族檬,否則報(bào)錯(cuò)
-
5.開火事件:當(dāng)在一個(gè)頁面操作時(shí)允耿,在另一個(gè)頁面也做一些操作
- 開火方
mui.plusReady(function(){})
document.getElementById("btn").addEventListener("tap",function(){
var login_page = plus.webview.getWebviewById("login.html");
mui.fire(login_page,"hello",{name:"jinwangba"}); # hello 是開火到另一個(gè)頁面的事件,{name:"jinwangba"}是傳過去的值
})
- 接受方
document.addEventListener("hello",function(data){
mui.toast(data.detail.name )
})
- 點(diǎn)亮首頁按鈕
開火方:
document.getElementById("clear_btn").addEventListener("tap",function(){
var index = plus.webview.getWebviewById("HBuilder");
mui.fire(index,"dianliangshouye");
})
接受方
document.addEventListener("dianliangshouye",function(){
var index_btn = document.getElementById("index_page");
var set_btn = document.getElementById("setting");
index_btn.className = "mui-tab-item mui-active";
set_btn.className ="mui-tab-item" # 熄滅別的
})
HBuilder 是首頁的id
-
6.post 請求
ajax文檔
document.getElementById("login_btn").addEventListener("tap",function(){
var username = document.getElementById("username").value;
var pwd = document.getElementById("pwd").value;
mui.post(
"http://192.168.12.11:9527/login",
{"username":username,"password":pwd},
function(data){
mui.toast(data.msg);
open_user_info(data.data);
}
)
})
登錄成功直接跳轉(zhuǎn)
document.getElementById("login_btn").addEventListener("tap",function(){
var username = document.getElementById("username").value;
var pwd = document.getElementById("pwd").value;
mui.post(
"http://192.168.12.11:9527/login",
{"username":username,"password":pwd},
function(data){
mui.toast(data.msg);
open_user_info(data.data);
}
)
})
function open_user_info(user_info){
mui.openWindow({
url:"user_info.html",
id:"user_info.html",
styles:{
top:"0px",
bottom:"50px"
},
extras:user_info
})
}
打開頁面直接顯示傳過來的數(shù)據(jù)
mui.plusReady(function(){
var Sdata = plus.webview.currentWebview();
document.getElementById("username").innerText = Sdata.username;
document.getElementById("user_id").innerText = Sdata.user_id;
document.getElementById("nickname").innerText = Sdata.nickname;
})