使用 img onload 判断图片是否加载完成

loadImage (url) {
            const image = new Image()
            image.src  = url
            image.onerror  = () => {
                console.log('图片加载失败')
                this.showLoading = false
            }
            image.onload = () => {
          //图片加载完成 this.bgImage = image.src this.showLoading = false } },

  

posted on 2020-04-29 14:24  朽白  阅读(1170)  评论(0)    收藏  举报

导航