/* ---page/test/test.wxml----*/
<
button
type
=
"default"
bindtap
=
"actionSheetTap"
>彈出菜單選項</
button
>
<
action-sheet
hidden
=
"{{actionSheetHidden}}"
bindchange
=
"actionSheetChange"
>
<
action-sheet-item
bindtap
=
"item1"
>選項一</
action-sheet-item
>
<
action-sheet-item
bindtap
=
"item2"
>選項二</
action-sheet-item
>
<
action-sheet-cancel
class
=
"cancel"
>取消</
action-sheet-cancel
>
</
action-sheet
>
/* ---page/test/test.wxml----*/
|
/* ---page/test/test.js----*/
Page({
data: {
actionSheetHidden:
true
,
//設置選項框是否顯示
},
totoSheet:
function
(){
//當選項卡隱藏則打開,打開時則隱藏
this
.setData({
actionSheetHidden: !
this
.data.actionSheetHidden
})
},
actionSheetTap:
function
(e) {
this
.totoSheet();
},
actionSheetChange:
function
(e) {
this
.totoSheet();
},
item1:
function
(){
console.log(
"我是第一個選擇項"
);
this
.totoSheet();
},
item2:
function
(){
console.log(
"我是第二個選擇項"
);
this
.totoSheet();
}
})
/* ---page/test/test.js----*/
|
屬性名 | 類型 | 默認值 | 說明 |
---|---|---|---|
hidden | Boolean | true | 是否隱藏 |
bindchange | EventHandle |
|
點擊背景或action-sheet-cancel按鈕時觸發change事件,不攜帶數據 |
/* ---page/test/test.wxml----*/
<
modal
title
=
"標題"
confirm-text
=
"confirm"
cancel-text
=
"cancel"
hidden
=
"{{modalHidden}}"
bindconfirm
=
"modalChange"
bindcancel
=
"modalChange"
>
這是對話框一的內容。
</
modal
>
<
modal
class
=
"modal"
hidden
=
"{{modalHidden2}}"
no-cancel
bindconfirm
=
"modalChange2"
>
<
view
> 沒有標題沒有蒙層沒有肯定的modal </
view
>
<
view
> 內容能夠插入節點 </
view
>
</
modal
>
<
view
class
=
"btn-area"
>
<
button
type
=
"default"
bindtap
=
"modalTap"
>點擊彈出modal</
button
>
<
button
type
=
"default"
bindtap
=
"modalTap2"
>點擊彈出modal2</
button
>
</
view
>
/* ---page/test/test.wxml----*/
|
/* ---page/test/test.js----*/
Page({
data: {
modalHidden:
true
,
modalHidden2:
true
},
modalTap:
function
(e) {
this
.setData({
modalHidden:
false
})
},
modalChange:
function
(e) {
this
.setData({
modalHidden:
true
})
},
modalTap2:
function
(e) {
this
.setData({
modalHidden2:
false
})
},
modalChange2:
function
(e) {
this
.setData({
modalHidden2:
true
})
},
})
/* ---page/test/test.js----*/
|
屬性名 | 類型 | 默認值 | 說明 |
---|---|---|---|
title | String |
|
標題 |
hidden | Boolean | false | 是否隱藏整個彈窗 |
no-cancel | Boolean | false | 是否隱藏cancel按鈕 |
confirm-text | String | 肯定 | confirm按鈕文字 |
cancel-text | String | 取消 | cancel按鈕文字 |
bindconfirm | EventHandle |
|
點擊確認觸發的回調 |
bindcancel | EventHandle |
|
點擊取消以及蒙層觸發的回調 |
/* ---page/test/test.wxml----*/
<
toast
hidden
=
"{{toast1}}"
bindchange
=
"toast1Change"
>默認(1500毫秒消失)</
toast
>
<
toast
hidden
=
"{{toast2}}"
duration
=
"500"
bindchange
=
"toast2Change"
>500毫秒後消失</
toast
>
<
button
type
=
"default"
bindtap
=
"toast1Tap"
>點擊彈出默認toast</
button
>
<
button
type
=
"default"
bindtap
=
"toast2Tap"
>點擊彈出設置duration的toast</
button
>
/* ---page/test/test.wxml----*/
|
/* ---page/test/test.js----*/
Page({
data : {
toast1 :
true
,
toast2 :
true
,
},
toast1Tap :
function
(){
this
.setData({
toast1 :
false
})
},
toast2Tap :
function
(){
this
.setData({
toast2 :
false
})
},
toast1Change:
function
(){
this
.setData({
toast1 :
true
})
},
toast2Change:
function
(){
this
.setData({
toast2 :
true
})
}
})
/* ---page/test/test.js----*/
|
/* ---page/test/test.wxml----*/
<
loading
hidden
=
"{{hidden}}"
>加載中...</
loading
>
<
button
type
=
"default"
bindtap
=
"loadingTap"
>點擊彈出loading</
button
>
/* ---page/test/test.wxml----*/
|
/* ---page/test/test.js----*/
Page({
data: {
hidden:
true
},
loadingTap:
function
(){
this
.setData({
hidden:
false
});
var
that =
this
;
setTimeout(
function
(){
that.setData({
hidden:
true
});
that.update();
}, 3000);
}
})
/* ---page/test/test.js----*/
|
屬性名 | 類型 | 默認值 | 說明 |
---|---|---|---|
hidden | Boolean | false | 是否隱藏 |