您当前的位置: 首页 > 知识百科 > 微信小程序弹出菜单怎么开发?

微信小程序弹出菜单怎么开发?

时间:2023-07-01 14:05 阅读数:15 人阅读 分类:知识百科

  微信小程序弹出菜单有很多种表现形式,微信小程序商城已经介绍过一些资料了,小编接着为大家讲解一下弹出菜单的四种形式以及开发教程。

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

  


  [html] view plain copy//show.js

  //获取应用实例

  var app = getApp()

  Page({

  showok:function() {

  wx.showToast({

  title: '成功',

  icon: 'success',

  duration: 2000

  })

  }

  })

  


  2.模态弹窗——wx.showModal(OBJECT)

  


  [html] view plain copy//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)

  


  [html] view plain copy//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属*来进行选择。

  [html] view plain copy

  modal有输入框

  [html] view plain copy//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

  })

  }

  })

  


  以上就是关于微信小程序弹出菜单的具体内容和流程,参照这个教程,大家想要什么样的弹出效果都能进行开发,更多问题请留言与小编探讨。

  

  微信小程序弹出层的开发和使用

  微信小程序如何弹出输入框?

  微信小程序怎么开发弹出菜单特效?不弹出键盘?