在路由器中-> index.js
编写子路由并在父路由中写入-此时写入的任何全局组件,
并在孩子们写下我们想展示的地方
const router = new VueRouter({
mode: "history",
base: process.env.BASE_URL,
routes: [
{ path: "/", redirect: "/login" },
{ path: "/registration", component: registration },
{
path: "/home",
component: navbar,
children: [
{
path: "/home",
name: "home",
component: () => import("../views/Home.vue"),
},
{
path: "/notes",
name: "notes",
component: () => import("../views/notes/Index.vue"),
},
{
path: "/notes/create",
name: "notescreate",
component: () => import("../views/notes/Create.vue"),
},
{
path: "/notes/edit/:id",
name: "notesedit",
component: () => import("../views/notes/Edit.vue"),
},
{ path: "/myposts", component: myPosts },
{ path: "/allposts", component: allPosts },
{ path: "/create", component: create },
{ path: "/edit/:id", component: edit },
],
},
{
path: "/login",
name: "login",
component: () => import("../views/Login.vue"),
},
],
});
别忘了写在app.vue中
没有路由器视图 - 它不会工作