详解微信小程序 template添加绑定事件
对于模板的使用,我是想将模板的事件单独出来,其他引用模板的页面中不再掺杂模板事件,比较方便管理,如果还有其他好的解决办法, 请赐教。
template.wxml
rush:xml;">
template.js
rush:js;">
var temp = {
clickView: function () {
console.log("刚刚您点击了temp")
}
}
export default temp
template.wxss
rush:js;">
.tempClass {
background-color: red;
}
index.wxml 引用template模板
rush:js;">
body
index.js
rush: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
rush:js;">
/**index.wxss**/
@import "../temp/temp.wxss";
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。