Interesting problem!
I’d use vm.$root.$on and vm.$root.$emit to be able to control a component from outside.
vm.$root.$on
vm.$root.$emit
<template> <div> <FullPageError /> <component :is=“crtActionBar” /> <App /> </div> </template> <script> export default { data: () => ({ crtActionBarName: ‘action1’, }), computed: { crtActionBar () { return () => import(`path/to/dir/actionBars/${this.crtActionBarName}`) } }, created () { this.$root.$on(‘changeActionBar’, actionBarName => { this.crtActionBarName = actionBarName; }) } } </script>
Now from your child component, where you want to change parent’s data from.
created () { this.$root.$emit(‘changeActionBar’, ‘action2’); }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Interesting problem!
I’d use
vm.$root.$on
andvm.$root.$emit
to be able to control a component from outside.Now from your child component, where you want to change parent’s data from.