/* ---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 | 是否隐藏 |