欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

Vue 3: 如何创建和使用子页面?

最编程 2024-02-01 10:24:51
...
import { createRouter, createWebHashHistory } from "vue-router"; // 引入文件 import Home from "../views/Home.vue"; import About from "../views/About.vue"; import Attach from "../views/Attach.vue"; // import Sy from "../views/Sy.vue"; import Cs from "../views/Cs.vue"; const routes = [ { path: "/Attach", redirect: Attach, }, { path: "/home", //假如home为登录页面 name: "home", component: Home, }, { path: "/", name: "About", //为首页 component: About, children: [ //子页面 { path: "/", name: "Attach", component: Attach, }, { path: "/Cs", name: "Cs", component: Cs, }, { path: "/sy", name: "sy", component: sy, } ], }, ]; const router = createRouter({ routes, history: createWebHashHistory(), });

推荐阅读