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
This article is mainly for those who do not under...
Preface Sometimes you come across business tables...
This article shares with you how to use Vue to lo...
Vue recommends using templates to create your HTM...
This article shares the MySQL 5.7.18 MSI installa...
There are currently three ways to display the cen...
pssh is an open source software implemented in Py...
Problem description: When inserting Chinese chara...
The main text page of TW used to have a width of 8...
Table of contents background analyze Data simulat...
Table of contents 1. Responsive principle foundat...
In MySQL, fields of char, varchar, and text types...
Background: I wonder if you have noticed that if ...
This article example shares the specific code for...
The implementation idea of the javascript game ...