[Vuejs]-Vue.js render from child into parent when needed just like router-view

1👍

So I think you’re saying you want to change the content of the page header depending on the child.

Components cannot directly affect the templates of other components in the tree. Slots give you some control over this, but it is limited to allowing a component to inject templates into sections of a child component, not the other way around.

Your options are:

  1. Add logic to your parent component which detects what child component is shown and then change the page header accordingly. The page header won’t be controlled directly by the child component, though.

  2. Use named views with vue-router.

  3. Use something like portal-vue, but don’t go crazy with this kind of power…

Leave a comment