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
Note that this is not a project created by vue-cl...
After the National Day holiday, did any of you fi...
1. Single row overflow 1. If a single line overfl...
Recently, the client of a project insisted on hav...
Recently, a friend asked me a question: When layo...
I. Introduction 1: SSL Certificate My domain name...
1. Download the installation package -Choose the ...
Table of contents Preface Actual Combat 1. No loc...
Table of contents Introduction How to connect to ...
HTTP Status Codes The status code is composed of ...
This article example shares the specific code of ...
Plot Review In the previous article, we analyzed ...
When using MySQL, we often sort and query a field...
Table of contents 1. Common higher-order function...
Shopify Plus is the enterprise version of the e-c...