技术&日志

微信小程序 template添加绑定事件

template.wxml

<view bindtap="clickView" class="tempClass">temp模板</view>

template.js

var temp = {
 clickView: function () {
  console.log("刚刚您点击了temp")
 }
}
export default temp

index.js

const App = getApp()
import tempObj from '../temp/temp'

//index.js
//获取应用实例
var indexObj = {
 onShow() {
  console.log("onShow")
 }
}
indexObj["clickView"] = tempObj.clickView
Page(indexObj)

相关资料

详解微信小程序 template添加绑定事件

发表评论