When developing a Vue project, you often need to implement a page that can switch to display different component pages. For example: In the figure below, by clicking on different components in the sidebar, you can be routed to different component pages, while the sidebar and the top part remain unchanged, and only the component page is switched . At this time, we need to use the router-view component (also called routing placeholder) in the route First, we come to the page where we need to switch different component pages and add the router-view component where we need it. <template> <!--Header area--> <el-header> <div> <img class="shop" src="../assets/img/shop.png" alt=""> <span>E-commerce backend management system</span> </div> <el-button type="info" @click="logout">Logout</el-button> </el-header> <el-container> <!--Sidebar--> <!--This is simplified for easy understanding. It means clicking on different options in the sidebar to jump to the route--> <router-link :to="/roles"></router-link><!--Role list--> <router-link :to="/rights"></router-link><!--Permission list--> <!--Route placeholder--> <router-view></router-view> </template> The route corresponding to the role list is /roles, and the route corresponding to the permission list is /rights. index.js { path:'/home', component:Home, // Redirect to the role list redirect:'/roles', children:[ { path:'/rights', component:Rights }, { path:'/roles', component:Roles } ] } In this way, we have realized the use of the router-view component! This is the end of this article about the detailed use of the router-view component in Vue. For more relevant content on the use of the Vue router-view component, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: What is Nginx load balancing and how to configure it
>>: CSS uses the autoflow attribute to achieve seat selection effect
Because the data binding mechanism of Vue and oth...
Open the scheduled task editor. Cent uses vim to ...
Table of contents Use of Vue mixin Data access in...
1. Enter the host machine of the docker container...
1. Monitoring planning Before creating a monitori...
Temporary tables and memory tables A memory table...
In the previous article, I introduced the basic k...
Only show the top border <table frame=above>...
Tomcat itself optimization Tomcat Memory Optimiza...
Previously, the images we used were all pulled fr...
This article uses examples to illustrate the simp...
Table of contents 1. List interface display examp...
1. Problem The project developed using Eclipse on...
The configuration is very simple, but I have to c...
Environment: CentOS 7.1.1503 Minimum Installation...