一、wx.showToast(Object object)
1. Code implementation
wx.showToast({
title: '内容', //提示的内容
duration: 2000, //持续的时间
icon: 'loading', //图标有success、error、loading、none四种
mask: true //显示透明蒙层 防止触摸穿透
})
2. Mimic pop-up effect
二 、wx.showModal(Object object)
1. Code implementation
wx.showModal({
title: '我是标题', //提示的标题
content: '我是内容', //提示的内容
success: function(res) {
if(res.confirm) {
console.log('用户点击了确定')
} else if (res.cancel) {
console.log('用户点击了取消')
}
}
})
2. Mimic pop-up effect
三、wx.showLoading(Object object)
Display the loading prompt box. You need to actively call wx.hideLoading to close the prompt box
1. Code implementation
wx.showLoading({
title: '加载中',
})
setTimeout(function () {
wx.hideLoading()
}, 2000)
2. Mimic pop-up effect
Notice:
wx.showLoading and wx.showToast can only display one wx.showLoading at the same time and should be paired with wx.hideLoading.
四、wx.showActionSheet(Object object)
1. Code implementation
wx.showActionSheet({
itemList:['选项一','选项二','其它'], //文字数组
success: (res) => {
switch(res.tapIndex) {
case 0:
console.log('点击了 选项一')
break;
case 1:
console.log('点击了 选项二')
break;
case 2:
console.log('点击了 其它选项')
break;
}
},
fail (res) {
console.log('取消选项')
}
})
2. Mimic pop-up effect