I have a layout structured like this:
.------------------------+----------------.
| Current Tab Title | Controls |
+------------------------+----------------+
| Tab1 Tab2 [Tab3] |
+-----------------------------------------+
| Main Content |
| |
'-----------------------------------------'
The content in the "Controls" field should logically correspond to the current tab. However, due to rendering constraints, I cannot place it in the same Vue component as the tab itself. Additionally, the tab title should dynamically change based on the active tab.
To achieve this, I used the <router-link>
components for Tab1
, etc. and leveraged the $route.name
field for the tab title. I explored using named views to display the controls.
However, I am struggling to figure out how to synchronize and interact with the state in the current tab from the controls within the Controls
block.
For instance, I want to include a checkbox for Tab1
that affects the tab's behavior. This state should be managed within the Tab1
component rather than the Tab1Controls
component. How can I pass the current checkbox value from the Tab1
instance to the Tab1Controls
instance, and vice versa?
While this can be achieved using Vuex
, I am exploring alternative solutions. The common advice is to lift state up the component hierarchy, but this approach seems challenging with the router. Moreover, storing the checkbox data in either the Tab1
or Tab1Controls
components exclusively is preferable, as it is not relevant to other tabs.