index.vue 849 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <!--
  2. * @Author: wjc
  3. * @Date: 2025-04-09 10:19:11
  4. * @LastEditors: wjc
  5. * @LastEditTime: 2026-01-16 14:28:09
  6. * @Description: 自定义图片预览组件
  7. -->
  8. <template>
  9. <nut-image-preview :show="show" :images="images" @close="onClose" />
  10. <image mode="aspectFit" @click="onShow" />
  11. </template>
  12. <script setup lang="ts">
  13. defineOptions({
  14. name: 'MImage',
  15. options: {
  16. styleIsolation: 'shared',
  17. virtualHost: true,
  18. },
  19. })
  20. const props = withDefaults(
  21. defineProps<{
  22. src: string[]
  23. }>(),
  24. {
  25. src: () => [],
  26. }
  27. )
  28. watchEffect(() => {
  29. images.value = props.src.map((item) => {
  30. return {
  31. src: item,
  32. }
  33. })
  34. })
  35. const images = ref([])
  36. const show = ref(false)
  37. const onShow = () => {
  38. show.value = true
  39. }
  40. const onClose = () => {
  41. show.value = false
  42. }
  43. </script>