欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

使用微信小程序開(kāi)發(fā)彈出框應(yīng)用實(shí)例詳解

 更新時(shí)間:2018年10月18日 15:20:00   作者:面條請(qǐng)不要欺負(fù)漢堡  
本文通過(guò)實(shí)例代碼給大家介紹了使用微信小程序開(kāi)發(fā)彈出框功能,代碼簡(jiǎn)單易懂,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

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>

1.消息提示——wx.showToast(OBJECT)

//show.js
//獲取應(yīng)用實(shí)例 
var app = getApp() 
Page({
	showok:function() {
		wx.showToast({
		 	title: '成功',
		 	icon: 'success',
		 	duration: 2000
		})
	}
})

2.模態(tài)彈窗——wx.showModal(OBJECT)

//show.js
//獲取應(yīng)用實(shí)例 
var app = getApp() 
Page({
	showok:function() {
		wx.showToast({
		 	title: '成功',
		 	icon: 'success',
		 	duration: 2000
		})
	}
})

//show.js
//獲取應(yīng)用實(shí)例 
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)

//show.js
//獲取應(yīng)用實(shí)例 
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彈出

指定哪個(gè)modal,可以通過(guò)hidden屬性來(lái)進(jìn)行選擇。

<!--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>
//show.js 
//獲取應(yīng)用實(shí)例 
var app = getApp() 
Page({
	data:{
  hiddenmodalput:true,
  //可以通過(guò)hidden是否掩藏彈出框的屬性,來(lái)指定那個(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
	 })
 }
})

總結(jié)

以上所述是小編給大家介紹的使用微信小程序開(kāi)發(fā)彈出框應(yīng)用實(shí)例詳解,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論