In my child component I have an custom click handler that emits an event like this:
this.$emit('nextslide');
And in my parent component I try to catch the event like this:
render(createElement) {
return createElement(
'div',
{
on: {
nextslide: this.triggerFunction,
}
},
this.$slots.default,
)
},
I get no errors at all but it is also not working. I'm wondering if you can actually catch and event like this.
The page:
<carousel>
<slide-next>
</slide-next>
</carousel>
Carousel.vue:
<script>
export default {
render(createElement) {
return createElement(
'div',
{
on: {
nextslide: this.triggerFunction,
}
},
this.$slots.default,
)
},
methods: {
triggerFunction() {
console.log('this should trigger');
},
}
}
</script>
SlideNext.vue
<script>
export default {
render(createElement) {
return createElement(
'div',
{
on: {
click: this.clickHandler
},
},
'Next')
},
methods: {
clickHandler() {
this.$emit('nextslide');
console.log('trigger emit');
},
},
}
</script>