小程序
小游戏
企业微信
微信支付
扫描小程序码分享
一般来说,在子组件内定义this.triggerEvent()就可以调用父组件的方法了,如下
// 组件 my-component.js
Component({
methods: {
onTap:
function
(){
this.triggerEvent('customevent', {})
this
.triggerEvent(
'customevent'
, {})
this.triggerEvent('customevent2', {})
'customevent2'
this.triggerEvent('customevent3', {})
'customevent3'
this.triggerEvent('customevent4', {})
'customevent4'
}
})
然后在不同的页面监听不同的customevent事件
加粗
标红
插入代码
插入链接
插入图片
上传视频
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号