zoukankan      html  css  js  c++  java
  • 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)
  • 相关阅读:
    修改表结构
    enum/set 约束
    MYSQL 数据类型
    表和数据的基础操作
    存储引擎
    mysql
    HTML 介绍
    selor模块
    select
    协程
  • 原文地址:https://www.cnblogs.com/czly/p/14497472.html
Copyright © 2011-2022 走看看