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
Usually, there are two options when we develop Li...
login.html part: <!DOCTYPE html> <html l...
GitHub has all kinds of magic tools. Today I foun...
question The code has no prompt: Many non-front-e...
To achieve an effect similar to Windows forms, dr...
XHTML is the standard website design language cur...
This article shares the specific code of the firs...
Software version and platform: MySQL-5.7.17-winx6...
download: Step 1: Open the website (enter the off...
MySQL 8 Windows version zip installation steps (d...
The following content introduces the process and ...
Execute the create table statement in the databas...
apt install CMake sudo apt install cmake This met...
Preface There are a lot of information and method...
Preface In many management and office systems, tr...