这篇文章主要为大家详细介绍了vue图片加载与显示默认图片的实例代码,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本文实例为大家分享了vue图片加载与显示默认图片的具体代码,供大家参考,具体内容如下
HTML:
<div class="content-show-img"> <div class="show-img"> </div></div>
JS:
Vue.prototype.successLoadImg = function(event) { if (event.target.complete == true) { event.target.classList.remove("default-image");; var imgParentNode = event.target.parentNode; if(imgParentNode.classList.contains('show-img')==true){ imgParentNode.style.background = "#000"; } } }; Vue.prototype.errorLoadImg = function(event) { event.target.classList.add("default-image");; }; <p>本文来源gao!%daima.com搞$代*!码9网(</p>
针对尺寸不统一的:先显示默认图片,加载成功时移除默认图片,填充背景。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持gaodaima搞代码网。
以上就是vue图片加载与显示默认图片实例代码的详细内容,更多请关注gaodaima搞代码网其它相关文章!