mpvue小程序加载不出图片 Failed to load local image resource /images/xx.png

在使用mpvue开发小程序添加静态本地图片时会报错,原因有多种。解决办法可修改webpack或mpvue的包,这里提供直接办法,因static是专门存放静态资源文件的,放在根目录下即可直接使用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

mpvue开发小程序时候,要添加静态本地图片

<img src="../../images/bg.png" alt="">

会报错:

VM14878:2 Failed to load local image resource /images/bg.png 
the server responded with a status of 404 (HTTP/1.1 404 Not Found) 

原因有很多种,解决办法可以改webpack,或mpvue的包,这里提供一个非常直接的办法:

直接写 /static/img/xx.png

比如:把图片放在根目录下的static文件下
<img src="/static/img/bg.png" >

就可以了

在这里插入图片描述
原因也很简单,static就是专门放静态资源文件的,存放在根目录下,直接就可以用

产品大全页面所有的按钮都改成橙色,现有代码中,通过编译后可以跳转到各页面,但过了一秒后自动跳转到开发者工具,但无报错信息,请帮我修复完成后给我完整代码。[Deprecation] SharedArrayBuffer will require cross-origin isolation as of M92, around July 2021. See https://developer.chrome.com/blog/enabling-shared-array-buffer/ for more details. [system] WeChatLib: 3.8.9 (2025.6.17 19:09:25) [system] No. of subpackages: 5 [system] LazyCodeLoading: false [wxobs] auto recording mode is not enabled in devtools. [体验分析] 为避免影响调试,开发者工具在非自定义启动模式下不会启动采集。详见 https://dev.weixin.qq.com/docs/analysis/sdk/debugging.html app.js? [sm]:47 小程序初始化完成 {path: "pages/welcome/welcome", query: {…}, scene: 1001, referrerInfo: {…}, mode: "default", …} wx.getSystemInfoSync is deprecated.Please use wx.getSystemSetting/wx.getAppAuthorizeSetting/wx.getDeviceInfo/wx.getWindowInfo/wx.getAppBaseInfo instead. getSystemInfo @ app.js? [sm]:68 onLaunch @ app.js? [sm]:50 (anonymous) @ app.js? [sm]:1 app.js? [sm]:70 系统信息: {batteryLevel: 97, benchmarkLevel: -1, brand: "devtools", memorySize: 2048, model: "iPhone 12/13 (Pro)", …} [Perf] App.getSystemInfo took 1292ms onLaunch @ app.js? [sm]:50 (anonymous) @ app.js? [sm]:1 app.js? [sm]:90 当前环境: develop, API地址: https://dev-api.lyqf.com app.js? [sm]:118 用户未登录 app.js? [sm]:156 开发环境自动跳转至首页 [Perf] App.onLaunch took 1360ms (anonymous) @ app.js? [sm]:1 app.js? [sm]:142 小程序切前台 {path: "pages/welcome/welcome", query: {…}, scene: 1001, referrerInfo: {…}, mode: "default", …} [Deprecation] SharedArrayBuffer will require cross-origin isolation as of M92, around July 2021. See https://developer.chrome.com/blog/enabling-shared-array-buffer/ for more details. [Perf] App.smartNavigateTo took 51ms (anonymous) @ app.js? [sm]:161 setTimeout (async) handleDevRedirect @ app.js? [sm]:159 onLaunch @ app.js? [sm]:62 (anonymous) @ app.js? [sm]:1 [system] Launch Time: 8480 ms [自动热重载] 已开启代码文件保存后自动热重载 app.js? [sm]:383 成功跳转至标签页: /pages/home/home [渲染层网络层错误] Failed to load local image resource /images/location.png the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [渲染层网络层错误] Failed to load local image resource /images/search.png the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [渲染层网络层错误] Failed to load local image resource /images/banner1.jpg the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [渲染层网络层错误] Failed to load local image resource /images/banner2.jpg the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [渲染层网络层错误] Failed to load local image resource /images/banner3.jpg the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [渲染层网络层错误] Failed to load local image resource /images/banner4.jpg the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [渲染层网络层错误] Failed to load local image resource /images/product/enterprise.png the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [渲染层网络层错误] Failed to load local image resource /images/product/individual.png the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [渲染层网络层错误] Failed to load local image resource /images/product/company.png the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [渲染层网络层错误] Failed to load local image resource /images/product/personal.png the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [渲染层网络层错误] Failed to load local image resource /images/product/worker.png the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [渲染层网络层错误] Failed to load local image resource /images/product/farmer.png the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [渲染层网络层错误] Failed to load local image resource /images/product/edu.png the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [渲染层网络层错误] Failed to load local image resource /images/product/house.png the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [渲染层网络层错误] Failed to load local image resource /images/product/car.png the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [渲染层网络层错误] Failed to load local image resource /images/product/clue.png the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [渲染层网络层错误] Failed to load local image resource /images/service/incubation.png the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [渲染层网络层错误] Failed to load local image resource /images/service/tech.png the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [渲染层网络层错误] Failed to load local image resource /images/service/loan.png the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [渲染层网络层错误] Failed to load local image resource /images/service/assets.png the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [渲染层网络层错误] Failed to load local image resource /images/service/finance.png the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [渲染层网络层错误] Failed to load local image resource /images/service/ecommerce.png the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [渲染层网络层错误] Failed to load local image resource /images/news1.jpg the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [渲染层网络层错误] Failed to load local image resource /images/news2.jpg the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: Windows,mp,1.06.2503300; lib: 3.8.9) [自动热重载] 已开启代码文件保存后自动热重载 login.js? [sm]:58 开发环境跳转中... [自动热重载] 已开启代码文件保存后自动热重载 app.js? [sm]:383 成功跳转至标签页: /pages/home/home [worker] reportRealtimeAction:fail not support
06-28
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值