微信小程序 如何实现js点击事件

版权声明:博客知识产权来源命运的信徒,切勿侵权 https://blog.csdn.net/qq_37591637/article/details/89508805

坑啊


我一直做的是html的网站或者是手机app  

js点击事件 都是  onclick="事件名()"


但是微信小程序真的是刷新我的三观

html页面如下,你没有看错bindtap绑定

  <button formType="button" class="search_btn" bindtap='search'>搜索</button>    

js代码

//index.js
const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    
  },

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

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

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


  // 点击事件
  search: function (e) {
  console.log("eeee");
  },
})

猜你喜欢

转载自blog.csdn.net/qq_37591637/article/details/89508805