Vue路由的嵌套(chidren)

Vue路由的嵌套(chidren)1 index js 引入路由组件 import UserRoot from views UserRoot vue const routes path name HomeView component HomeView component

大家好,我是讯享网,很高兴认识大家。

1、index.js引入路由组件

import UserRoot from '../views/UserRoot.vue' const routes = [ { path: "/", name: "HomeView", // component: HomeView component: () => import('../views/HomeView.vue') //懒加载设置,需要这个组件时,才开始调用 }, { path: "/aboutview", //父路由地址 name: "AboutView", redirect: "/AboutView/AboutChild",//重定向 // component: AboutView component: () => import('../views/AboutView.vue'), children: [ //添加两个子路由 { path: 'AboutChild', name: 'AboutChild', component: AboutChild }, { path: 'AboutChild1', name: "AboutChild1", component: AboutChild1 } ] }, ]

讯享网

2、父路由渲染(例子上的AboutView)


讯享网

讯享网<template> <div> <!-- <StudentName /> --> <router-link to="/AboutView/AboutChild">AboutChild</router-link> | //路径需要写全 <router-link to="/AboutView/AboutChild1">AboutChild1</router-link> <router-view></router-view> </div> </template>

小讯
上一篇 2025-03-22 20:22
下一篇 2025-03-25 17:07

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/128696.html