cheetah-framework
Version:
Cheetah Framework JS used in all our applications
17 lines (14 loc) • 394 B
JavaScript
/**
* This directive will forward events to parent component.
*/
const directive = {
inserted: function (el, binding, vnode) {
if (binding.value) {
const eventNames = binding.value.split(/[\s,]+/)
_.each(eventNames, eventName => {
vnode.componentInstance.$on(eventName, data => (vnode.context.$emit(eventName, data)))
})
}
}
}
export default directive