最近学习vue过程中,发现路径当中总是存在一个#号,比如这个:
这种情况是因为在入口js文件中,如果你不更改设置的话,vue会默认使用hash模式,该模式下回将路径格式化为 # 开头。
如果需要美化路径,可以更改模式为 history :
router 里面的index.js配置里面
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
const routes = [
{
path: '/about',
name: 'about',
meta: {
title: '关于',
auth: false
},
component: () => import(/* webpackChunkName: "about" */ '../view/About.vue')
}
]
const router = new Router({
mode: 'history',
base: process.env.BASE_URL,
routes
})
export default router
这样就把路径里的#号去除了,是不是好看了很多呢?
Original: https://www.cnblogs.com/b10100912/p/16851742.html
Author: 面向CV工程师
Title: vue项目去除访问路径中的#号(Vue 访问路径开启history 模式)
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/685190/
转载文章受原作者版权保护。转载请注明原作者出处!