• vue3中使用vue-router


    安装vue-router

    npm install vue-router@4.0.0-beta.13

    创建src/router/index.js

    import { createRouter, createWebHashHistory } from 'vue-router'
    
    const router = createRouter({
      history: createWebHashHistory(), // hash模式:createWebHashHistory,history模式:createWebHistory
      routes: [
        {
          path: '/',
          redirect: '/home'
        },
        {
          path: '/home',
          name: 'home',
          component: () => import(/* webpackChunkName: "home" */ '@/views/home.vue'),
          meta: {
            index: 1
          }
        },
        {
          path: '/test',
          name: 'test',
          component: () => import(/* webpackChunkName: "login" */ '@/views/testDemo.vue'),
          meta: {
            index: 1
          }
        } 
      ]
    })
    
    export default router

    main.js中

    import router from './router'
    
    app.use(router)
  • 相关阅读:
    BJDCTF-WP
    Python 每日一练(4)
    Python 每日一练(3)
    BUUCTF Crypto
    Python每日一练(1)
    Python 每日一练(2)
    oracle 组函数
    oracle 组函数
    oracle
    前端实战遇到问题
  • 原文地址:https://www.cnblogs.com/czly/p/14497472.html
Copyright © 2020-2023  润新知