1. Routing Configurationconst routes = [ { path: '/', name: 'Navigation 1', component: Home, children:[ { path: '/customer', name: 'Customer', // route level code-splitting // this generates a separate chunk (about.[hash].js) for this route // which is lazy-loaded when the route is visited. component: () => import(/* webpackChunkName: "about" */ '../views/Customer.vue') }, { path: '/pageOne', name: 'Page 1', component: PageOne, }, { path: '/pageTwo', name: 'Page 2', component: PageTwo, }, ] }, { path: '/navigation', name: 'Navigation 2', component: Home, children:[ { path: '/pageThree', name: 'Page 3', component: PageThree, }, { path: '/pageFour', name: 'Page 4', component: PageFour }, ] }, 2. Vue page nestingApp.vue first configures the first router-view // An highlighted block <router-view></router-view> Home.vue configures the second router-view // An highlighted block <template> <div> <el-container style="height: 500px; border: 1px solid #eee"> <el-aside width="200px" style="background-color: rgb(238, 241, 246)"> <el-menu> <el-submenu v-for="(item,index) in $router.options.routes" :index="index+''"> <template slot="title"><i class="el-icon-sell"></i>{{item.name}}</template> <el-menu-item v-for="(item2,index2) in item.children" :index="index+'-'+index2">{{item2.name}}</el-menu-item> </el-submenu> </el-menu> </el-aside> <el-container> <el-header style="text-align: right; font-size: 12px"> <el-dropdown> <i class="el-icon-setting" style="margin-right: 15px"></i> <el-dropdown-menu slot="dropdown"> <el-dropdown-item>View</el-dropdown-item> <el-dropdown-item>New</el-dropdown-item> <el-dropdown-item>Delete</el-dropdown-item> </el-dropdown-menu> </el-dropdown> <span>Wang Xiaohu</span> </el-header> <el-main> <router-view></router-view> </el-main> </el-container> </el-container> </div> </template> <style> .el-header { background-color: #B3C0D1; color: #333; line-height: 60px; } .el-aside { color: #333; } </style> <script> export default { }; </script> 3. Nested Relationships First, when you visit http://localhost:8181/, you will enter the first level of nesting, and then enter the first router-view: Home.vue. Then when pageone is accessed, Home.vue will be accessed as well. Because the nested display of router-view is related to the nested routing path, you can see that in the routing, under the path of navigation one are the routing paths of page one and page two respectively. So when accessing page one, the parent path Home.vue page will be accessed first. If you add Home.vue page without placing router-view, the lower-level pages will not be displayed This is the end of this article about the nested display implementation of vue router-view. For more related vue router-view nested display content, 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:
|
<<: Use Python to connect to MySQL database using the pymysql module
>>: Install JDK8 in rpm mode on CentOS7
Preface Recently, my computer often takes a long ...
Table of contents 1. MySQL replication process 2....
Modify the simplified file size and download the ...
Whitelist rule syntax: BasicRule wl:ID [negative]...
Table of contents 1. Display and hide by default ...
1. First log in to the Alibaba Cloud website to r...
Table of contents Preface React Functional Compon...
Table of contents JavaScript events: Commonly use...
Table of contents background example Misconceptio...
Use the Vue-Cropper component to upload avatars. ...
The author of this article @子木yoyo posted it on hi...
Now most projects have begun to be deployed on Do...
Recently, I happened to be in touch with the vue+...
Table of contents Deploy tomcat 1. Download and d...
Table of contents 1. Make good use of components ...