详解微信小程序 template添加绑定事件
2017-06-23 09:05
656 查看
详解微信小程序 template添加绑定事件
对于模板的使用,我是想将模板的事件单独出来,其他引用模板的页面中不再掺杂模板事件,比较方便管理,如果还有其他好的解决办法, 请赐教。
template.wxml
<view bindtap="clickView" class="tempClass">temp模板</view>
template.js
var temp = { clickView: function () { console.log("刚刚您点击了temp") } } export default temp
template.wxss
.tempClass { background-color: red; }
index.wxml 引用template模板
<!--index.wxml--> <view>body</view> <include src="../temp/temp.wxml" />
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**/ @import "../temp/temp.wxss";
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
您可能感兴趣的文章:
相关文章推荐
- 微信小程序 template添加绑定事件
- 微信小程序之绑定点击事件实例详解
- 微信小程序 页面跳转事件绑定的实例详解
- 微信小程序 template添加点击事件
- 微信小程序,关于navigator子元素绑定事件,阻止navigator跳转
- 微信小程序WXML 数据绑定、列表渲染、条件渲染、模板、事件、引用用法
- 微信小程序 循环列表添加点击事件和样式
- 微信小程序视图template模板引用的实例详解
- C#中控件动态添加事件绑定的时机详解
- 微信小程序 后台https域名绑定和免费的https证书申请详解
- 微信小程序 事件冒泡,bangtap,catchtap事件绑定
- 微信小程序 后台https域名绑定和免费的https证书申请详解
- 微信小程序项目总结:for循环,绑定点击事件,二维数组列表渲染 ...
- 微信小程序页面跳转事件绑定/冒泡,非冒泡事件
- 微信小程序 js动态给前台元素绑定事件
- jquery html动态添加的元素绑定事件详解
- 微信小程序开发详解(五)---微信小程序事件
- 微信小程序 数据绑定详解及实例
- 微信小程序 template模板详解及实例
- 微信小程序-事件绑定、样式引入、模板引用