微信小程序自定义组件绑定外部方法
最近做小程序要自定义组件,涉及到自定义组件抛出并绑定外部方法,下面代码就是绑定关键
index.wxml
<customComponent bind:action="selectItemDetail"/>index.js
selectItemDetail:function(){ //doSomeThings },调用外部方法,主要是通过triggerEvent来启动外部方法
customComponent.js
methods: { selectItem:function() { this.triggerEvent("action"); } }绑定事件方法
customComponent.wxml
<button class="actionBtn" bindtap='selectItem'>小程序声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。

