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

网友投稿 249 2023-05-06


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

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

对于模板的使用,我是想将模板的事件单独出来,其他引用模板的页面中不再掺杂模板事件,比较方便管理,如果还有其他好的解决办法, 请赐教。

template.wxml

temp模板

template.js

var temp = http://{

clickView: function () {

console.log("刚刚您点击了temp")

}

}

export default temp

template.wxss

.tempClass {

background-color: red;

}

index.wxml 引用template模板

body

index.js

const App = getApp()

import tempObj from '../temp/temp'

//index.js

//获取应用实例

var indexObj = {

onShow() {

console.log("onShow")

}

}

indexObj["clickView"] = tempObj.clickView

Page(indexObj)

index.wxss

/**index.wxss**/http://

@import "../temp/temp.wxss";

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:接口是怎么实现的(接口的实现方式)
下一篇:小发现之浅谈location.search与location.hash的问题
相关文章

 发表评论

暂时没有评论,来抢沙发吧~