企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 语法: ## 在上级路由里加children:[ ] ~~~ children:[ {path:'pay',component: Pay}, {path:'nopay',component: NoPay} ] ~~~ ![](https://img.kancloud.cn/6e/b4/6eb4ac58b22f8a0c0b6711c5f48b14b7_2365x1349.png) ![](https://img.kancloud.cn/7e/0c/7e0ce00bb8b4dd5effd15ac729abb23c_2066x962.png) ## 代码案例: ~~~ import Vue from 'vue' import VueRouter from 'vue-router' import Index from '../views/index' import Goods from '../views/Goods' import Detail from '../views/goods/Detail' import User from '../views/User' import Pay from "../views/user/Pay" //引入页面 import NoPay from "../views/user/NoPay" //引入页面 Vue.use(VueRouter) const routes = [ {path:'/', component:Index }, {path:'/goods', component:Goods }, { path:'/goods/detail/:id', component: Detail, }, {path:'/user', //栏目导航页面 component:User, children:[ {path:'pay',component: Pay}, //嵌套路由 {path:'nopay',component: NoPay} //嵌套路由 ] } ] const router = new VueRouter({ routes }) export default router ~~~ 栏目页里加载: ![](https://img.kancloud.cn/d2/23/d223a79270ce7747daebe02cb7f673e3_1828x545.png) ## 代码案例: ~~~ <template> <div> <ul class="user"> <router-link tag="li" to="/user/pay">已付款</router-link> <router-link tag="li" to="/user/nopay">未付款</router-link> </ul> <router-view></router-view> </div> </template> <script> export default { } </script> <style scoped> .user{ text-align: center; } .user li{ list-style:none; display:inline; margin:40px; } </style> ~~~