微信小程序開發中toast也是重要的消息提示方式.
提示框:
wx.showToast(OBJECT)
顯示消息提示框
OBJECT參數說明:

示例代碼:
-
wx.showToast({
-
title:'成功',
-
icon:'success',
-
duration: 2000
-
})
-
wx.hideToast()
隱藏消息提示框
-
wx.showToast({
-
title:'加載中',
-
icon:'loading',
-
duration: 10000
-
})
-
-
setTimeout(function(){
-
wx.hideToast()
-
},2000)
-
wx.showModal(OBJECT)
顯示模態彈窗
OBJECT參數說明:

示例代碼:
-
wx.showModal({
-
title:'提示',
-
content:'這是一個模態彈窗',
-
success:function(res) {
-
if(res.confirm) {
-
console.log('用戶點擊確定')
-
}
-
}
-
})
-
wx.showActionSheet(OBJECT)
-
顯示操作菜單
OBJECT參數說明:

success返回參數說明:

示例代碼:
-
wx.showActionSheet({
-
itemList: ['A','B', 'C'],
-
success:function(res) {
-
if(!res.cancel) {
-
console.log(res.tapIndex)
-
}
-
}
-
})
設置導航條
-
<view>提示:{{tip}}</view>
-
<button type="default" bindtap="showModal">點擊我彈出modal對話框</button>
-
<view>
-
<modal title="modal對話框" hidden="{{modalHidden}}" confirm-text="確定" cancel-text="取消"
|