其他分享
首页 > 其他分享> > vue3 路由hash与History的设置

vue3 路由hash与History的设置

作者:互联网

一、history

关键字:createWebHistory

import { createRouter, createWebHistory } from 'vue-router'
const routes = [ {
  path: '/userinfo',
  name: 'UserInfo',
  component: () => import('../views/UserInfo.vue')
}]
const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})
export default router

二、hash

关键字:createWebHashHistory

import { createRouter, createWebHashHistory } from 'vue-router'
const routes = [{
  path: '/userinfo',
  name: 'UserInfo',
  component: () => import('../views/UserInfo.vue')
}]
const router = createRouter({
  history: createWebHashHistory(),
  routes
})
export default router

标签:vue,const,import,createRouter,UserInfo,vue3,router,hash,History
来源: https://blog.csdn.net/john987321456/article/details/113827678