1π
β
It looks like you are emitting the event before the component is created and registers to listen for the event. So, instead of this:
this.$emit('imgClicked', id);
this.$router.push({ name: 'OeModal', params: {id: id}})
try this:
this.$router.push({ name: 'OeModal', params: {id: id}})
this.$emit('imgClicked', id);
or potentially:
this.$router.push({ name: 'OeModal', params: {id: id}})
this.$nextTick(function () {
this.$emit('imgClicked', id);
});
Also, how you are registering your event handler is incorrect. Instead of this:
this.$parent.$on('imgClicked', this.$modal.show('testModal'));
try this:
this.$parent.$on('imgClicked', function () { this.$modal.show('testModal'); });
π€David K. Hess
Source:stackexchange.com