ZZJ
2022-07-27 013c4922a3296e95a54c1902c09b44d62a000eb2
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>