Reputation: 159
In Vue, I've got a component named Container. It is composed of two components ComponentA and ComponentB. Here is the code for the Vue app Https:/codesandbox.io/s/p5po0jz47
How can a router be configured to navigate to ComponentB on ComponentA?
Upvotes: 1
Views: 75
Reputation: 1458
I had a similar challenge. The way I handled it was registering both components within the container, using the <component></component>
tag in the container template, and using Vuex to manage the current <component is="">
value.
So Component A may have a button to transition to Component B, which would then trigger a Vuex mutation that updates a Vuex state object like {currentComponent: ""}
, then a Vuex getter would feed the <component is="">
binding in the container component. There are easier ways to do this, I'm sure, but in my use case I wanted the selection persisted.
Upvotes: 1