vuecli4 vue3.0改变路径为hash路径

history: createWebHashHistory(process.env.BASE_URL), hash 路由

createWebHistory history 路由

createMemoryHistory 带缓存 history 路由

parseQuery 查询参数反序列化

stringifyQuery 查询参数序列化

onBeforeRouteLeave 路由离开钩子

import { createRouter, createWebHashHistory } from 'vue-router'
import Home from '../views/Home.vue'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    meta:{
      title:'home'
    }
  },
  {
    path: '/about',
    name: 'About',
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  }
]

const router = createRouter({
  
  history: createWebHashHistory(process.env.BASE_URL),
  routes,

})

export default router

转载链接:https://www.jianshu.com/p/2b7001c0b6e0

原文地址:https://www.cnblogs.com/lst619247/p/13603402.html