频道栏目
首页 > 资讯 > 微信小程序 > 正文

小程序弹出框详解教程

19-01-16        来源:[db:作者]  
收藏   我要投稿

小程序弹出框详解


  1. qjlx: function() {
  2. var itemList = ['病假', '事假'];
  3. wx.showActionSheet({
  4. itemList: itemList,
  5. success: function(res) {
  6. console.log(res);
  7. console.log(itemList[res.tapIndex]);
  8. },
  9. fail: function(res) {
  10. console.log(res.errMsg);
  11. }
  12. })
  13. },

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

效果

效果

 

  1. //获取应用实例
  2. var app = getApp()
  3. Page({
  4. actioncnt:function(){
  5. wx.showActionSheet({
  6. itemList: ['A', 'B', 'C'],
  7. success: function(res) {
  8. console.log(res.tapIndex)
  9. },
  10. fail: function(res) {
  11. console.log(res.errMsg)
  12. }
  13. })
  14. }
  15. })

弹出框

 

  1. 登录密码
  2.  
  3.  
  4.  
  5.  
  6.  
 

  1. // js
  2. // 获取登录密码:
  3. password: function(e) {
  4. this.setData({
  5. password: e.detail.value,
  6. })
  7. console.log("获取登录密码:" + this.data.password);
  8. },
  9. // 修改登录密码
  10. dlmm: function(e) {
  11. this.setData({
  12. hiddenmodalput: !this.data.hiddenmodalput
  13. })
  14. },
  15. cancelM: function(e) {
  16. this.setData({
  17. hiddenmodalput: true,
  18. })
  19. },
  20.  
  21. confirmM: function(e) {
  22. var that = this;
  23. console.log("原密码" + that.data.psd + "新密码" + that.data.newpsd);
  24. that.setData({
  25. hiddenmodalput: true,
  26. })
  27. wx.request({
  28. url: '',
  29. method: 'POST',
  30. header: {
  31. 'Authorization': 'Bearer' + wx.getStorageSync('token'),
  32. },
  33. success(res) {
  34. if (res.data.code == 0) {
  35. wx.showToast({
  36. title: '保存失败',
  37. icon: 'success',
  38. duration: 500
  39. })
  40. } else {
  41. that.getShowToast();
  42. }
  43. }
  44. })
  45. },
  46.  
  47. ipsd: function(e) {
  48. this.setData({
  49. psd: e.detail.value
  50. })
  51. },
  52. newipsd: function(e) {
  53. this.setData({
  54. newpsd: e.detail.value
  55. })
  56. },

指定modal弹出

效果

 

  1.  
  2.  
 

  1. //获取应用实例
  2. var app = getApp()
  3. Page({
  4. data:{
  5. hiddenmodalput:true,
  6. //可以通过hidden是否掩藏弹出框的属性,来指定那个弹出框
  7. },
  8. //点击按钮痰喘指定的hiddenmodalput弹出框
  9. modalinput:function(){
  10. this.setData({
  11. hiddenmodalput: !this.data.hiddenmodalput
  12. })
  13. },
  14. //取消按钮
  15. cancel: function(){
  16. this.setData({
  17. hiddenmodalput: true
  18. });
  19. },
  20. //确认
  21. confirm: function(){
  22. this.setData({
  23. hiddenmodalput: true
  24. })
  25. }
  26.  
  27. })

效果

 

  1. //获取应用实例
  2. var app = getApp()
  3. Page({
  4. actioncnt:function(){
  5. wx.showActionSheet({
  6. itemList: ['A', 'B', 'C'],
  7. success: function(res) {
  8. console.log(res.tapIndex)
  9. },
  10. fail: function(res) {
  11. console.log(res.errMsg)
  12. }
  13. })
  14. }
  15. })
 

  1.  
  2.  
  3.  
  4. //.js
  5. //获取应用实例
  6. var app = getApp()
  7. Page({
  8. data:{
  9. hiddenmodalput:true,
  10. //可以通过hidden是否掩藏弹出框的属性,来指定那个弹出框
  11. },
  12.  
  13. //点击按钮痰喘指定的hiddenmodalput弹出框
  14. modalinput:function(){
  15. this.setData({
  16. hiddenmodalput: !this.data.hiddenmodalput
  17. })
  18. },
  19. //取消按钮
  20. cancel: function(){
  21. this.setData({
  22. hiddenmodalput: true
  23. });
  24. },
  25. //确认
  26. confirm: function(){
  27. this.setData({
  28. hiddenmodalput: true
  29. })
  30. }
  31. })

结语

下面我将继续对 其他知识 深入讲解 。

相关TAG标签
上一篇:怎么掌握微信小程序的取值、传值、数据存储实例
下一篇:小程序白屏问题和内存研究教程
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站