Instead of binding a custom event in the mounted()
method, I want to bind it on the root tag directly. So, I attempted the following code:
render (h) {
return (
<div on-custom-event={this.handleCustomEvent}></div>
)
}
However, when testing it in Chrome, I realized that the custom-event
was bound to the DOM and couldn't be triggered using $emit
. With VueJS 2's template syntax, this can be easily achieved like so:
<template>
<div @custom-event="handleCustomEvent"></div>
</template>
If you have any insights or solutions to this issue, your help is greatly appreciated. Thank you!