如何将vue-router默认的hash模式改为history模式
时间:2020-09-14 20:05:40
收藏:0
阅读:439
vue-router的默认根路径是‘#‘,如果不想要‘#‘就可以使用history模式。
在router的配置文件下加入
export default new Router({
mode:‘history‘, //改为history模式
})
此时本地可以访问到路径,但是打包过后页面出现空白,在保证静态资源路径加载正确的情况下,原因可能是项目的根路径不是域名,
export default new Router({
mode:‘history‘, //改为history模式
base: ‘/dist/‘, //项目根路径
})
此时我们线上访问的路径就是https://域名/dist/index
原文:https://www.cnblogs.com/panzai/p/13667255.html
评论(0)