image-format.vue 602 Bytes
<template>
  <img v-lazy="currentSrc" :alt="alt" v-if="lazy">
  <img :src="currentSrc" :alt="alt" v-else>
</template>

<script>
export default {
  name: 'ImageFormat',
  props: {
    lazy: {
      type: Boolean,
      default: true
    },
    src: String,
    width: Number,
    height: Number,
    alt: String,
  },
  data() {
    return {
      refresh: false
    };
  },
  watch: {
    src() {
      this.lazy = false;
    }
  },
  computed: {
    currentSrc() {
      return (this.src || '')
        .replace('{width}', this.width)
        .replace('{height}', this.height);
    }
  }
};
</script>