Vite + Vue3 项目打包部署后页面空白

1,175 阅读1分钟

服务端上传

image.png

文件有预览功能,于是直接预览,预览地址如下:

xxx.com/aaa/index.h…

页面空白,source 中只有 index.html 引用的 js 和 css,没有其他资源:

25da61f520b1ffe27008fad78771e68.png

Vue-router 也没有渲染:

image.png

测试:

显示 app test

<router-view></router-view> 没有渲染:

image.png

本地预览:

npm run preview

http://127.0.0.1:8080/index 页面正常

http://127.0.0.1:8080/index.html 表现和服务器上一样

线上直接访问 /html:

xxx.com/aaa/index

image.png

现在看来就是常规的服务端配置的问题。

router.vuejs.org/zh/guide/es…

nginx

location / {
  try_files $uri $uri/ /index.html;
}