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");; };
针对尺寸不统一的:先显示默认图片,加载成功时移除默认图片,填充背景。
以上是“vue中如何实现图片加载与显示默认图片”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!