vue3 路由hash与History的设置
一、history关键字:createWebHistoryimport { createRouter, createWebHistory } from 'vue-router'const routes = [ {path: '/userinfo',name: 'UserInfo',component: () => import('../views/UserInfo.vue')}]const
·
一、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
更多推荐
已为社区贡献2条内容
所有评论(0)