Pass parameters with EventEmitter

Source: https://stackoverflow.com/questions/35390765/pass-parameters-with-eventemitter


@Output() stopSort = new EventEmitter();
EventEmitter supports one argument, which is passed as $event to your event handler.
Wrap your parameters in an event object when you pass it to emit:
this.stopSort.emit({ event:event, ui: ui });
Then, when you handle the event, use $event:
stopSort($event) { 
  alert('event param from Component: ' +$event.event);
  alert('ui param from Component: ' + $event.ui);
}

Không có nhận xét nào:

StaticImage

  import React , { useEffect , useRef } from "react" import { StaticImage } from "gatsby-plugin-image" impor...