vue history模式打包后页面为空白页
首先先确定是不是路径的问题,如果找不到css文件和js文件,那么要修改config下面的index.js中bulid模块导出的路径assetsPublicPath: '/',改为assetsPublicPath: './',确定路径没问题以后再来看history模式的问题history模式需要服务器端配置详情见:https://router.vuejs.org/zh-cn/essentials/h
·
首先先确定是不是路径的问题,如果找不到css文件和js文件,那么要修改config下面的index.js中bulid模块导出的路径
assetsPublicPath: '/',
改为
assetsPublicPath: './',
确定路径没问题以后再来看history模式的问题
history模式需要服务器端配置
详情见:https://router.vuejs.org/zh-cn/essentials/history-mode.html
vue默认的是hash模式,表现为浏览器的网页地址带 # 符号,当然,你可能会碰到需求说要你把这个#给去掉,那么你就需要history模式了
export default new Router({
mode: 'history',
}
打包上传以后还是空白页,但是各个资源都是有的,资源路径也都是可以打开的
这里你还需要修改两个地方
1.你的子路径需要加上去,
2.给每一个component加上name
export default new Router({
mode: 'history',
base: '/test',
routes: [
{ path: '/index', name: 'index', component:index},
}
打包上传测试
更多推荐
所有评论(0)