ZZJ
2022-07-11 6ef2ac92c0d3f79b59b8698274918df830b58b29
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>