Mini Program development encountered a problem: how to pass the value of the child component to the parent component

Component({
  properties: {}
  methods: {
    onTap: function(){
      var myEventDetail = {} // detail
      var myEventOption = {} // 
      this.triggerEvent("myevent", myEventDetail, myEventOption)
    }
  }
})

this is a custom event given in the official document, which is triggered by triggerEvent, so if I want to pass a custom component parameter to this" myevent", I don"t seem to see the method.


Component

Component({
  properties: {},

  data: {
    info:''
  },

  methods: {
    modalClear:function(){
      let myEventDetail = this.data.info;
      this.triggerEvent('myevent',myEventDetail,{bubbles:false});
    }
  }
})

index.wxml

//
<my-component modal-hidden="{{is_modal_Hidden}}" modal-msg="{{is_modal_msg}}" bind:myevent='onMyevent'></my-component>

index.js

  onMyevent:function(e){
    console.log(e.detail);
  }

clipboard.png


are you talking about listening for event delivery?
this.triggerEvent ('myevent', {myEventDetail, myEventOption})

Menu