当前位置:首页站长学院后端开发微信小程序开发弹出框实现方法
企业营销,就选知企PROSAAS

微信小程序开发弹出框实现方法

本文主要和大家分享微信小程序开发弹出框实现方法,本文所分享的代码很清晰,希望能帮助到大家。

微信小程序开发弹出框实现方法

<view class="container" class="zn-uploadimg">
	<button type="primary"bindtap="showok">消息提示框</button> 
	<button type="primary"bindtap="modalcnt">模态弹窗</button> 
	<button type="primary"bindtap="actioncnt">操作菜单</button> 
</view>

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

微信小程序开发弹出框实现方法
//show.js
//获取应用实例  
var app = getApp()  
Page({
	showok:function() {
		wx.showToast({
		  	title: '成功',
		  	icon: 'success',
		  	duration: 2000
		})
	}
})

微信小程序开发弹出框实现方法
2.模态弹窗——wx.showModal(OBJECT)


微信小程序开发弹出框实现方法

//show.js
//获取应用实例  
var app = getApp()  
Page({
	modalcnt:function(){
		wx.showModal({
			title: '提示',
			content: '这是一个模态弹窗',
			success: function(res) {
				if (res.confirm) {
				console.log('用户点击确定')
				} else if (res.cancel) {
				console.log('用户点击取消')
				}
			}
		})
	}
})

微信小程序开发弹出框实现方法


3.操作菜单——wx.showActionSheet(OBJECT)



//show.js
//获取应用实例  
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弹出

微信小程序开发弹出框实现方法

指定哪个modal,可以通过hidden属性来进行选择。


<!--show.wxml-->
<view class="container" class="zn-uploadimg">
	<button type="primary"bindtap="modalinput">modal有输入框</button> 
</view>
<modal hidden="{{hiddenmodalput}}" title="请输入验证码" confirm-text="提交" cancel-text="重置" bindcancel="cancel" bindconfirm="confirm">
    <input type='text'placeholder="请输入内容" auto-focus/>
</modal>
//show.js 
//获取应用实例  
var app = getApp()  
Page({
	data:{
        hiddenmodalput:true,
        //可以通过hidden是否掩藏弹出框的属性,来指定那个弹出框
    },
	//点击按钮痰喘指定的hiddenmodalput弹出框
	modalinput:function(){
		this.setData({
		   hiddenmodalput: !this.data.hiddenmodalput
		})
	},
	//取消按钮
	cancel: function(){
        this.setData({
            hiddenmodalput: true
        });
    },
    //确认
    confirm: function(){
        this.setData({
	        hiddenmodalput: true
	    })
    }
    
})

微信小程序开发弹出框实现方法
相关推荐:

如何用JQuery写出登录弹出框

推荐10款实现弹出框特效(收藏)

分享HTML5实现弹出框的效果示例

以上就是微信小程序开发弹出框实现方法的详细内容,更多请关注知企PROSAAS其它相关文章!

温馨提示:

文章标题:微信小程序开发弹出框实现方法

文章链接:https://ceshi.prosaas.cn/17717.html

更新时间:2018年03月17日

声明: 本站大部分内容均收集于网络!若内容若侵犯到您的权益,请发送邮件至:973664285@qq.com我们将第一时间处理! 资源所需价格并非资源售卖价格,是收集、整理、编辑详情以及本站运营的适当补贴,并且本站不提供任何免费技术支持。 所有资源仅限于参考和学习,版权归原作者所有,更多请阅读知企PROSAAS协议

给TA打赏
共{{data.count}}人
人已打赏
后端开发

CSS和JS的加载和执行详解

2018-3-16 16:50:45

后端开发

微信小程序模拟下拉菜单开发实例

2018-3-17 12:16:18

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索