最近做小程序要自定义组件,涉及到自定义组件抛出并绑定外部方法,下面代码就是绑定关键

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'>小程序

TAG标签: 微信小程序微信地区怎么自定义

http://www.xiaochengxub.com/read-100525.html