mark
2022-10-25 f20a554bdb24e9dfde9dc6a69d78595944f61d15
src/components/subComponents/ImageShow.vue
@@ -1,5 +1,5 @@
<template>
  <img :src="url" alt="" />
  <img class="a111" @error="onError" :src="url" alt="" />
</template>
<script>
@@ -9,13 +9,32 @@
  },
  computed: {
    url() {
      if (this.src.indexOf("http://apps.smartai.com/httpImage/") === -1) {
        return "httpImage" + this.src;
      if (
        this.src &&
        this.src.indexOf("http://apps.smartai.com/httpImage/") === -1 &&
        this.src.indexOf("/images") !== 0
      ) {
        return "/httpImage/" + this.src;
      } else {
        return this.src;
      }
    },
  },
  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>