1. Click on the menu to jump1. Unify page naming We first unify the page names and use lowercase, change The sample code is as follows: import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router' import Home from '../views/home.vue' import About from '../views/about.vue' const routes: Array<RouteRecordRaw> = [ { path: '/', name: 'Home', component: Home }, { path: '/about', name: 'About', component: About // route level code-splitting // this generates a separate chunk (about.[hash].js) for this route //Lazy loading made me delete it} ] const router = createRouter({ history: createWebHistory(process.env.BASE_URL), routes }) export default router 2. Add management page Create a page called The sample code is as follows: <template> <div class="about"> <h1>E-book management page</h1> </div> </template> 3. Add routes Modify The sample code is as follows: import {createRouter, createWebHistory, RouteRecordRaw} from 'vue-router' import Home from '../views/home.vue' import About from '../views/about.vue' import AdminEbook from '../views/admin/admin-ebook.vue' const routes: Array<RouteRecordRaw> = [ { path: '/', name: 'Home', component: Home }, { path: '/about', name: 'About', component: About }, { path: '/admin/admin-ebook', name: 'AdminEbook', component: AdminEbook } ] const router = createRouter({ history: createWebHistory(process.env.BASE_URL), routes }) export default router 4. Bind the route in the menuWe modify it in the header, the sample code is as follows: <template> <a-layout-header class="header"> <div class="logo" /> <a-menu theme="dark" mode="horizontal" :style="{ lineHeight: '64px' }" > <a-menu-item key="/"> <router-link to="/">Home</router-link> </a-menu-item> <a-menu-item key="/admin/admin-ebook"> <router-link to="/admin/admin-ebook">E-book management page</router-link> </a-menu-item> <a-menu-item key="3"> <router-link to="/about">About Us</router-link> </a-menu-item> </a-menu> </a-layout-header> </template> <script lang="ts"> import {defineComponent} from 'vue'; export default defineComponent({ name: 'TheHeader', }); </script> Knowledge points: Use 2. Actual EffectRecompile and start, as shown below: This is the end of this article about the use of Vue3 pages, menus, and routes. For more information about the use of Vue3 pages, menus, and routes, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Example of implementing a seamless infinite loop of background using CSS animation
>>: Analyze the duration of TIME_WAIT from the Linux source code
I’ve always preferred grayscale images because I t...
Table of contents What is the rest operator? How ...
This article shares the specific code of js to ac...
In the article MySQL Optimization: Cache Optimiza...
Problem Description I want to achieve the followi...
<br />When uploading on some websites, a [Se...
Preface There are many ways to center horizontall...
1. Download the MySQL jdbc driver (mysql-connecto...
1. Understand the WEB Web pages are mainly compos...
This is a very important topic, not only for Linu...
1. Write a simple Java program public class tests...
Vue data two-way binding principle, but this meth...
1. 85% of ads go unread <br />Interpretatio...
Download tutorial of mysql-connector-java.jar pac...
First of all, let's talk about the execution ...