src/components/subComponents/ImageShow.vue
@@ -1,5 +1,5 @@ <template> <img class="a111" :src="url" alt="" /> <img class="a111" @error="onError" :src="url" alt="" /> </template> <script> @@ -20,6 +20,21 @@ } }, }, data() { return { errorNum: 0, }; }, methods: { onError(err) { console.log(err); if (this.errorNum > 5) { return; } err.target.src = this.url + "?" + Math.random(); this.errorNum++; }, }, }; </script>