打包后页面出现空白问题
2026/7/15 1:58:35 网站建设 项目流程

问题:打包后npm run build,生成dist文件,出现页面空白问题

---------------------------------------------------------------------------------------------------------------------------------

原因一、资源加载路径错误,即dist/index.html中的资源引用为相对路径,而不是/js/……

解决:在vue.config.js文件中,添加 publicPath: '/' 配置

原因二、路由模式为history(因为需要服务器端支持)

解决:将history模式改为hash模式 或 告诉后端需要重定向

在src/router/index.js中,

const router = new VueRouter({
mode: 'hash', // 将 'history' 改为 'hash'
routes
}

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询