当前位置:网站首页>Show default image when wechat applet image cannot be displayed
Show default image when wechat applet image cannot be displayed
2022-07-26 09:46:00 【44w0】
The recently developed project is wechat applet , Dynamic display pictures , There are some problems
- Pictures are online pictures obtained from other websites , Use image Labels cannot be displayed normally
Solution : Use native img label , Add attribute referrerPolicy=“no-referrer”
<img referrerPolicy="no-referrer" :src="item.picPath" >
At this point, the picture can be displayed
2. After that, I found that several pictures failed to load , Just let it display the default picture set by itself ( Wechat applet doesn't work )
Solution : Handle the problem of image loading failure , Use onerror Event capture image loading error , Use default picture
<img referrerPolicy="no-referrer" :src="item.picPath" onerror="οnerrοr=null;src='../../static/exam/b1.png'" ></img>
Be careful : οnerrοr=null Must not omit , Otherwise, the effect cannot be achieved
3. use h5 test onerror It is normal that the event capture image is loaded incorrectly , But if you use wechat applet, you will report an error , I went to Baidu again
Solution : Wechat applet img Tags do not support onerror event , Use @error Method
<img referrerPolicy="no-referrer" :src="item.picPath" @error="imageError($event, index)" ></img>
js part :
imageError(e, index) {
this.newFinal[index].picPath = '../../static/exam/b1.png';
},
Be careful : stay imageError Method to replace a picture that cannot be displayed with a local static picture , Note that the traversal object should be modified directly , If passing value item modify item, The default picture cannot be displayed
边栏推荐
- Customize permission validation in blazor
- JS judge the data types object.prototype.tostring.call and typeof
- Audio and video knowledge
- Fuzzy PID control of motor speed
- Flutter event distribution
- Solve proxyerror: CONDA cannot proceed due to an error in your proxy configuration
- 新公链Aptos何以拉满市场期待值?
- Alibaba cloud technology expert haochendong: cloud observability - problem discovery and positioning practice
- Basic knowledge of website design
- v-premission添加权限
猜你喜欢

一种分布式深度学习编程新范式:Global Tensor

苹果独占鳌头,三星大举复兴,国产手机在高端市场颗粒无收

matlab中的AR模型短时预测交通流

Great reward for interview questions

2021年山东省中职组“网络空间安全”B模块windows渗透(解析)

A new paradigm of distributed deep learning programming: Global tensor

面试突击68:为什么 TCP 需要 3 次握手?

QT handy notes (III) use qtcharts to draw a line chart in VS

Apple dominates, Samsung revives, and domestic mobile phones fail in the high-end market

Development to testing: a six-year road to automation starting from 0
随机推荐
antd TreeSelect获取父节点的值
E. Two Small Strings
Sqoop【环境搭建 01】CentOS Linux release 7.5 安装配置 sqoop-1.4.7 解决警告并验证(附Sqoop1+Sqoop2最新版安装包+MySQL驱动包资源)
copyTo
Sqoop【付诸实践 02】Sqoop1最新版 全库导入 + 数据过滤 + 字段类型支持 说明及举例代码(query参数及字段类型强制转换)
解决IE7 & IE8 存储cookie问题
Write a script that can run in Bash / shell and PowerShell
面试突击68:为什么 TCP 需要 3 次握手?
微信小程序AvatarCropper 头像裁剪
Antd treeselect gets the value of the parent node
Does volatile rely on the MESI protocol to solve the visibility problem? (top)
【Datawhale】【机器学习】糖尿病遗传风险检测挑战赛
[fluorescent character effect]
C managed and unmanaged
The difference between thread join and object wait
Server and client dual authentication (2)
Use of OpenCV class
Add DLL
系统安装Serv-U后IIS出错提示:HRESULT:0x80070020
服务器环境配置全过程