Skip to content

Commit

Permalink
fix(web): 修复 配置了h5->router->base 为 ./ 引发的发行后部分图片不显示 (question#191286)
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed May 13, 2024
1 parent af151e6 commit 4bf08a6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/uni-h5/dist/index.umd.min.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/platforms/h5/helpers/get-real-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ function addBase (filePath) {
export default function getRealPath (filePath) {
// 相对路径模式对静态资源路径特殊处理
if (__uniConfig.router.base === './') {
filePath = filePath.replace(/^\.\/static\//, '/static/')
filePath = filePath.replace(/^\.\/assets\//, '/assets/')
// 如果包含static目录(根目录的static|分包的static|uni_modules的static)
if (filePath.indexOf('./') === 0 && (filePath.includes('/static/') || filePath.indexOf('./assets/') === 0)) {
filePath = filePath.slice(1)
}
}
if (filePath.indexOf('/') === 0) {
if (filePath.indexOf('//') === 0) {
Expand Down

0 comments on commit 4bf08a6

Please sign in to comment.