vuejs·路由router 使用
// vue.html <template> <router-link to="/">Home</router-link> | <router-link to="/about">About</router-link> <router-view/> </template>
// router/index.js import { createRouter, createWebHistory } from 'vue-router' import HomeView from '../views/HomeView.vue' const routes = [ //页面地址 { path: '/', name: 'home', component: HomeView }, { path: '/about', name: 'about', component: () => import('../views/AboutView.vue') } ] const router = createRouter({ history: createWebHistory(process.env.BASE_URL), routes }) export default router
576 Views