微信小程序 自定义对话框实例详解
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了微信小程序 自定义对话框实例详解,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2133字,纯文字阅读大概需要4分钟。
内容图文
![微信小程序 自定义对话框实例详解](/upload/InfoBanner/zyjiaocheng/347/4f6c62aa992344ba993e3c52b5ebb8c8.jpg)
微信小程序 自定义对话框实例详解
效果图:
index.wxml:
<button type="default" bindtap="clickbtn"> 点击 </button> <view class="commodity_screen" bindtap="hideModal" wx:if="{{showModalStatus}}"></view> <view animation="{{animationData}}" class="commodity_attr_box" wx:if="{{showModalStatus}}"> <!--对话框标题--> <view class="dialog-title"> 请输入内容 </view> <!--对话框输入部分--> <view class="input-view"> <input type="text" bindblur="input_content" class="input-style"/> </view> <!--对话框按钮--> <view class="line-top"> </view> <view class="btn-view"> <view class="btn-cancel" bindtap="click_cancel"> 取 消 </view> <view class="btn-line"> </view> <view class="btn-cancel" bindtap="click_ok"> 确 定 </view> </view> </view>
index.js:
var inputinfo = ""; var app = getApp() Page({ data: { animationData:"", showModalStatus:false }, onLoad: function () { }, showModal: function () { // 显示遮罩层 var animation = wx.createAnimation({ duration: 200, timingFunction: "linear", delay: 0 }) this.animation = animation animation.translateY(300).step() this.setData({ animationData: animation.export(), showModalStatus: true }) setTimeout(function () { animation.translateY(0).step() this.setData({ animationData: animation.export() }) }.bind(this), 200) }, clickbtn:function(){ if(this.data.showModalStatus){ this.hideModal(); }else{ this.showModal(); } }, hideModal: function () { // 隐藏遮罩层 var animation = wx.createAnimation({ duration: 200, timingFunction: "linear", delay: 0 }) this.animation = animation animation.translateY(300).step() this.setData({ animationData: animation.export(), }) setTimeout(function () { animation.translateY(0).step() this.setData({ animationData: animation.export(), showModalStatus: false }) }.bind(this), 200) }, click_cancel:function(){ console.log("点击取消"); this.hideModal(); }, click_ok:function(){ console.log("点击了确定===,输入的信息为为==",inputinfo); this.hideModal(); }, input_content:function(e){ console.log(e); inputinfo = e.detail.value; } })
源码下载:http://xiazai.jb51.net/201701/yuanma/modalTest(jb51.net).rar
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
内容总结
以上是互联网集市为您收集整理的微信小程序 自定义对话框实例详解全部内容,希望文章能够帮你解决微信小程序 自定义对话框实例详解所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。