微信小程序bindtap事件

bindtap就是点击事件

在wxml文件下

<button type="primary" bindtap="btnclick"> {{btnText}} </button>

在js文件下

Page({

  /**
   * 页面的初始数据
   */
  data: {
    text : "这里是内容" ,
    btnText : "这里是按钮",
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  },
  // 定义一个函数
  btnclick:function () {
    this.setData({ text: "点完之后的内容"})
  }
})

 

 

 

posted @ 2020-02-05 00:48  ziyuliu  阅读(8718)  评论(0编辑  收藏  举报