ajiebp2022
ajiebp2022
  • 发布:2025-09-09 14:03
  • 更新:2025-09-09 14:34
  • 阅读:33

【报Bug】微信小程序报错:Failed to load local image resource /pages/index/https/img/shadow-grey.png

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: macOS Tahoe Beta 26.0

第三方开发者工具版本号: 1.06.2504030

基础库版本号: 3.9.3

项目创建方式: CLI

CLI版本号: uni/3.0.0-4070620250821001 darwin-arm64 node-v22.17.1

操作步骤:

通过
···
npx degit dcloudio/uni-preset-vue#vite-ts .
···
创建项目,
之后使用

npx @dcloudio/uvm@latest

升级到最新版本

时候发布到微信小程序
在 dist/build/mp-weixin/common/vendor.js里面,查找 shadow-grey.png

代码如下:

const ec = (function () {  
        if (h(wx.preloadAssets)) {  
            const e = 'https'  
            setTimeout(() => {  
                wx.preloadAssets({ data: [{ type: 'image', src: e + '/img/shadow-grey.png' }] })  
            }, 3e3)  
        }  
        return function (e) {  
            return App(Li(e))  
        }

const e = 'https' 这个地方应该为地址,但是只是https。
所以,在微信开发者工具中报错:
Failed to load local image resource /pages/index/https/img/shadow-grey.png
the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error)

预期结果:
 if (d(wx.preloadAssets)) {  
    const e = 'https://cdn.dcloud.net.cn' //或者其它cdn地址  
    setTimeout(() => {  
        wx.preloadAssets({ data: [{ type: 'image', src: e + '/img/shadow-grey.png' }] })  
    }, 3e3)  
 }

实际结果:
if (d(wx.preloadAssets)) {  
    const e = 'https'  
    setTimeout(() => {  
        wx.preloadAssets({ data: [{ type: 'image', src: e + '/img/shadow-grey.png' }] })  
    }, 3e3)  
 }

bug描述:

微信开发者工具中报错:
Failed to load local image resource /pages/index/https/img/shadow-grey.png
the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error)

报错的package.json

{  
  "name": "uni-preset-vue",  
  "version": "0.0.0",  
  "scripts": {  
    "dev:custom": "uni -p",  
    "dev:h5": "uni",  
    "dev:h5:ssr": "uni --ssr",  
    "dev:mp-alipay": "uni -p mp-alipay",  
    "dev:mp-baidu": "uni -p mp-baidu",  
    "dev:mp-jd": "uni -p mp-jd",  
    "dev:mp-kuaishou": "uni -p mp-kuaishou",  
    "dev:mp-lark": "uni -p mp-lark",  
    "dev:mp-qq": "uni -p mp-qq",  
    "dev:mp-toutiao": "uni -p mp-toutiao",  
    "dev:mp-weixin": "uni -p mp-weixin",  
    "dev:mp-xhs": "uni -p mp-xhs",  
    "dev:quickapp-webview": "uni -p quickapp-webview",  
    "dev:quickapp-webview-huawei": "uni -p quickapp-webview-huawei",  
    "dev:quickapp-webview-union": "uni -p quickapp-webview-union",  
    "build:custom": "uni build -p",  
    "build:h5": "uni build",  
    "build:h5:ssr": "uni build --ssr",  
    "build:mp-alipay": "uni build -p mp-alipay",  
    "build:mp-baidu": "uni build -p mp-baidu",  
    "build:mp-jd": "uni build -p mp-jd",  
    "build:mp-kuaishou": "uni build -p mp-kuaishou",  
    "build:mp-lark": "uni build -p mp-lark",  
    "build:mp-qq": "uni build -p mp-qq",  
    "build:mp-toutiao": "uni build -p mp-toutiao",  
    "build:mp-weixin": "uni build -p mp-weixin",  
    "build:mp-xhs": "uni build -p mp-xhs",  
    "build:quickapp-webview": "uni build -p quickapp-webview",  
    "build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei",  
    "build:quickapp-webview-union": "uni build -p quickapp-webview-union",  
    "type-check": "vue-tsc --noEmit"  
  },  
  "dependencies": {  
    "@dcloudio/uni-app": "3.0.0-4070620250821001",  
    "@dcloudio/uni-app-harmony": "3.0.0-4070620250821001",  
    "@dcloudio/uni-app-plus": "3.0.0-4070620250821001",  
    "@dcloudio/uni-components": "3.0.0-4070620250821001",  
    "@dcloudio/uni-h5": "3.0.0-4070620250821001",  
    "@dcloudio/uni-mp-alipay": "3.0.0-4070620250821001",  
    "@dcloudio/uni-mp-baidu": "3.0.0-4070620250821001",  
    "@dcloudio/uni-mp-harmony": "3.0.0-4070620250821001",  
    "@dcloudio/uni-mp-jd": "3.0.0-4070620250821001",  
    "@dcloudio/uni-mp-kuaishou": "3.0.0-4070620250821001",  
    "@dcloudio/uni-mp-lark": "3.0.0-4070620250821001",  
    "@dcloudio/uni-mp-qq": "3.0.0-4070620250821001",  
    "@dcloudio/uni-mp-toutiao": "3.0.0-4070620250821001",  
    "@dcloudio/uni-mp-weixin": "3.0.0-4070620250821001",  
    "@dcloudio/uni-mp-xhs": "3.0.0-4070620250821001",  
    "@dcloudio/uni-quickapp-webview": "3.0.0-4070620250821001",  
    "vue": "^3.4.21",  
    "vue-i18n": "^9.1.9"  
  },  
  "devDependencies": {  
    "@dcloudio/types": "^3.4.8",  
    "@dcloudio/uni-automator": "3.0.0-4070620250821001",  
    "@dcloudio/uni-cli-shared": "3.0.0-4070620250821001",  
    "@dcloudio/uni-stacktracey": "3.0.0-4070620250821001",  
    "@dcloudio/vite-plugin-uni": "3.0.0-4070620250821001",  
    "@vue/runtime-core": "^3.4.21",  
    "@vue/tsconfig": "^0.1.3",  
    "typescript": "^4.9.4",  
    "vite": "5.2.8",  
    "vue-tsc": "^1.0.24"  
  }  
}  
2025-09-09 14:03 负责人:无 分享
已邀请:
DCloud_UNI_JBB

DCloud_UNI_JBB

uniapp 的依赖升级到最新的 3.0.0-alpha-4080120250821001 试试还有没有这个问题

ajiebp2022

ajiebp2022 (作者)

升级到你说的这个版本,没有这个问题了。e对应的是一个字符串。

  • DCloud_UNI_JBB

    OK,感谢反馈,有后续问题的话可以在 im 中私聊我

    2025-09-09 14:35

要回复问题请先登录注册