当前位置:网站首页>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
边栏推荐
- 面试突击68:为什么 TCP 需要 3 次握手?
- Development to testing: a six-year road to automation starting from 0
- 2019 ICPC Asia Yinchuan regional (water problem solution)
- spolicy请求案例
- Does volatile rely on the MESI protocol to solve the visibility problem? (top)
- 学习笔记之常用数组api 改变原数组和不改变原数组的有哪些?
- uni-app学习总结
- 在Blazor 中自定义权限验证
- Server and client dual authentication (2)
- B站这个视频我是跪着看完的
猜你喜欢
2019 ICPC Asia Yinchuan regional (water problem solution)
SSG框架Gatsby访问数据库,并显示到页面上
Development to testing: a six-year road to automation starting from 0
服务器、客户端双认证(2)
阿里云技术专家郝晨栋:云上可观测能力——问题的发现与定位实践
Great reward for interview questions
Azkaban【基础知识 01】核心概念+特点+Web界面+架构+Job类型(一篇即可入门Azkaban工作流调度系统)
Xiaobai makes a wave of deep copy and shallow copy
2021 windows penetration of "Cyberspace Security" B module of Shandong secondary vocational group (analysis)
Gauss elimination
随机推荐
v-premission添加权限
Explain automatic packing and unpacking?
Solve proxyerror: CONDA cannot proceed due to an error in your proxy configuration
[MySQL] understand the important architecture of MySQL (I)
QT随手笔记(六)——更新界面、截图、文件对话框
SSG framework Gatsby accesses the database and displays it on the page
Gauss elimination solves the inverse of matrix (Gauss)
JS table auto cycle scrolling, mouse move in pause
E. Two Small Strings
微信小程序AvatarCropper 头像裁剪
2022 zhongkepan cloud - server internal information acquisition and analysis flag
IIS error prompt after installing Serv-U: hresult:0x80070020
ie7设置overflow属性失效解决方法
SSG框架Gatsby访问数据库,并显示到页面上
Redis sentinel mode setup under Windows
Login module use case writing
Basic knowledge of website design
(二)面扫描仪与机械臂的手眼标定(眼在手外:九点标定)
Flutter event distribution
Qt随手笔记(三)在vs中使用QtCharts画折线图