微信小程序父组件调用子组件事件

父组件中的子组件:

 <count-down id="countDown"></count-down>

子组件count-down中有事件:

Component({
    methods: {
         closeGold() {
             console.log('close gold');
        },
    }
})

父组件调用子组件方法:

 let countDown = this.selectComponent('#countDown'); // 页面获取自定义组件实例
  
    countDown.closeGold(); // 通过实例调用组件事件

 

posted @ 2022-06-22 15:28  Magi黄元  阅读(1415)  评论(0编辑  收藏  举报