img-format.vue
738 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,
h: Number,
width: Number,
height: Number,
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>