当前位置: 首页 > news >正文

Vue-Router之嵌套路由

在路由配置中,配置children

import Vue from 'vue'
import VueRouter from 'vue-router'Vue.use(VueRouter)const router = new VueRouter({mode: 'history',base: import.meta.env.BASE_URL,routes: [{path: '/',redirect: '/home'},{path: '/home',name: 'home',component: () => import('../views/HomeView.vue'),children: [{path: 'news',name: 'news',component: () => import('../views/NewsView.vue'),},{path: 'message',name: 'message',component: () => import('../views/MessageView.vue'),},]},{path: '/about',name: 'about',component: () => import('../views/AboutView.vue')},]
})export default router

在子页面中,继续使用router-link与router-view

<script>
export default {name: "HomeView"
}
</script><template><div class="home-container"><h3>Home组件</h3><router-link to="/home/news">News</router-link><br><router-link to="/home/message">Message</router-link><router-view></router-view></div></template><style scoped>
.home-container {min-height: 150px;background-color: #f2f2f2;padding: 15px;
}</style>
http://www.lryc.cn/news/513906.html

相关文章:

  • MyBatis使用的设计模式
  • arm rk3588 升级glibc2.31到2.33
  • 【Linux系列】sed命令的深入解析:如何使用sed删除文件内容
  • C++ 设计模式:桥接模式(Bridge Pattern)
  • MATLAB中whitespacePattern函数用法
  • Django多字段认证的实现
  • 【AndroidAPP】权限被拒绝:[android.permission.READ_EXTERNAL_STORAGE],USB设备访问权限系统报错
  • SQL进阶技巧:如何分析连续签到领金币数问题?
  • 1、ELK的架构和安装
  • Vue2/Vue3使用DataV
  • 汇编环境搭建
  • Android 系统 `android.app.Fragment` 类的深度定制与常见问题解析
  • linux ueditor nginx https 后台配置项返回格式出错,上传功能将不能正常使用
  • 【机器学习 | 数据挖掘】时间序列算法
  • uniapp H5 对接 声网,截图
  • 家谱管理系统|Java|SSM|VUE| 前后端分离
  • 【LeetCode】200、岛屿数量
  • idea报错:There is not enough memory to perform the requested operation.
  • python ai ReAct 代理(ReAct Agent)
  • HTML入门教程|| HTML 基本标签(2)
  • MySQL root用户密码忘记怎么办(Reset root account password)
  • groovy:多线程 简单示例
  • SOME/IP 协议详解——序列化
  • 三、GIT与Github推送(上传)和克隆(下载)
  • 18.2、网络安全评测技术与攻击
  • 在 ArcGIS Pro/GeoScene Pro 中设计专题地图的符号系统
  • CSS2笔记
  • 移动端如何实现上拉加载
  • 【mysql】linux安装mysql客户端
  • YOLOv5部署到web端(flask+js简单易懂)