wxml代碼
<view class="container" class="zn-uploadimg">
<button type="primary"bindtap="showok">消息提示框</button>
<button type="primary"bindtap="modalcnt">模態(tài)彈窗</button>
<button type="primary"bindtap="actioncnt">操作菜單</button>
</view>

var? app = getApp()
Page({
showok:function(){
wx.showToast({
title:'成功',
icon:'success',
duration:2000
})
}
})
2,模態(tài)彈窗——wx.showModal(OBJECT)

var app = getApp()
Page({
modalcnt:function(){
wx.showModal({
title: '提示',
content: '這是一個(gè)模態(tài)彈窗',
success: function(res) {
if (res.confirm) {
console.log('用戶點(diǎn)擊確定')
} else if (res.cancel) {
console.log('用戶點(diǎn)擊取消')
}
}
})
}
})
3.操作菜單——wx.showActionSheet(OBJECT)

var app = getApp()?
Page({
actioncnt:function(){
wx.showActionSheet({
itemList: ['A', 'B', 'C'],
success: function(res) {
console.log(res.tapIndex)
},
fail: function(res) {
console.log(res.errMsg)
}
})
}
})
4.指定modal彈出

wxml:
<!--show.wxml-->
<view class="container" class="zn-uploadimg">
<button type="primary"bindtap="modalinput">modal有輸入框</button>
</view>
<modal hidden="{{hiddenmodalput}}" title="請(qǐng)輸入驗(yàn)證碼" confirm-text="提交" cancel-text="重置" bindcancel="cancel" bindconfirm="confirm">
? ? <input type='text'placeholder="請(qǐng)輸入內(nèi)容" auto-focus/>
</modal>
js代碼
//show.js
//獲取應(yīng)用實(shí)例?
var app = getApp()?
Page({
data:{
? ? ? ? hiddenmodalput:true,
? ? ? ? //可以通過hidden是否掩藏彈出框的屬性,來指定那個(gè)彈出框
? ? },
//點(diǎn)擊按鈕痰喘指定的hiddenmodalput彈出框
modalinput:function(){
this.setData({
? hiddenmodalput: !this.data.hiddenmodalput
})
},
//取消按鈕
cancel: function(){
? ? ? ? this.setData({
? ? ? ? ? ? hiddenmodalput: true
? ? ? ? });
? ? },
? ? //確認(rèn)
? ? confirm: function(){
? ? ? ? this.setData({
? ? ? ? hiddenmodalput: true
? ? })
? ? }
})