img-format.vue
778 Bytes
<template>
<img v-if="lazy" v-lazy="currentSrc" alt="" :width="width" :height="height">
<img v-else :src="currentSrc" alt="" :width="width" :height="height">
</template>
<script>
import {getImgUrl} from 'common/utils';
export default {
name: 'ImgFormat',
props: {
src: String,
w: [Number, String],
h: [Number, String],
width: [Number, String],
height: [Number, String],
lazy: Boolean,
mode: {
type: Number,
default: 2
}
},
computed: {
currentSrc() {
if (this.w > 0 && this.h > 0) {
return getImgUrl(this.src, this.w, this.h, this.mode);
}
return this.src;
}
}
};
</script>
<style>
</style>