|
|
<template>
|
|
|
<img v-if="lazy" v-lazy="currentSrc" alt="" :width="width" :height="height">
|
|
|
<img v-else :src="currentSrc" alt="" :width="width" :height="height">
|
|
|
<img v-else ref="image" :src="currentSrc" alt="" :width="width" :height="height">
|
|
|
</template>
|
|
|
|
|
|
<script>
|
...
|
...
|
@@ -27,6 +27,24 @@ export default { |
|
|
}
|
|
|
return this.src;
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
let timer;
|
|
|
let img = new Image();
|
|
|
let maxRetry = 30 * 1000;
|
|
|
let start = Date.now();
|
|
|
|
|
|
timer = setInterval(() => {
|
|
|
img.src = this.$refs.image.src;
|
|
|
|
|
|
if (!img.src) {
|
|
|
clearInterval(timer);
|
|
|
}
|
|
|
|
|
|
if (img.complete || Date.now() - start > maxRetry) {
|
|
|
clearInterval(timer);
|
|
|
}
|
|
|
}, 3000);
|
|
|
}
|
|
|
};
|
|
|
</script>
|
...
|
...
|
|