liveh5-nuxt/app/components/x-image/index.vue

30 lines
511 B
Vue
Raw Normal View History

<script setup>
/*
* 此组件的目的是使用该图片组件自带预览大图
* */
import { showImagePreview } from 'vant';
const props = defineProps({
src: {
type: String,
default: ''
},
preview: {
type: Boolean,
default: true
}
})
const showImage = () => {
if (props.preview) {
showImagePreview([props.src]);
}
}
</script>
<template>
<img
loading="lazy"
v-bind="{ ...props, ...$attrs }"
style="object-fit: cover"
@click="showImage"
>
</template>