Router View
We can use router to achieve
1. Prepare the page
Go to Ele.me (element-plus) to find your favorite page and import it as needed. Let’s implement it with your own example.
First import the layout container
and then the menu bar. Introduce
these two and see the effect first.
Now the basic page is ready.
2. Introduce router in js and allow container to use router
The container has this attribute, but the default value is false
and the corresponding text in the menu bar is changed to <router-link>
Put <router-view></router-view> in the position where you want to change the page.
For example, I want to switch pages in the main block
and then prepare to switch component pages.
Configure the router path for each component.
Note that this must be done To configure the subpath of this view, if the configuration is at the same level as home, then when the menu bar is clicked, the entire page will be replaced with a component page. The project
directory is shown in the figure.
Home is the main view, and test and test1 are components for switching