Vue: instance methods events

This commit is contained in:
Julien Le Coupanec 2017-12-01 13:38:05 +01:00
parent e49a31edf8
commit b04042f56a
1 changed files with 18 additions and 2 deletions

View File

@ -494,7 +494,23 @@ vm.$delete( target, key )
* ******************************************************************************************* */
// Listen for a custom event on the current vm. Events can be triggered by vm.$emit.
// The callback will receive all the additional arguments passed into these event-triggering methods.
vm.$on(event, callback)
// Listen for a custom event, but only once.
// The listener will be removed once it triggers for the first time.
vm.$once(event, callback)
// Remove custom event listener(s).
// If no arguments are provided, remove all event listeners;
// If only the event is provided, remove all listeners for that event;
// If both event and callback are given, remove the listener for that specific callback only.
vm.$off([event, callback])
// Trigger an event on the current instance.
// Any additional arguments will be passed into the listeners callback function.
vm.$emit(event, [args])
/* *******************************************************************************************