ImgPreview.vue 592 B

12345678910111213141516171819202122232425262728293031
  1. <template>
  2. <div class="img-viewer-box">
  3. <el-image-viewer
  4. v-if="state.visible"
  5. :url-list="props.imgs"
  6. @close="close"
  7. />
  8. </div>
  9. </template>
  10. <script setup>
  11. import { ref, reactive } from "vue";
  12. import { useVModel } from "@vueuse/core";
  13. const props = defineProps();
  14. const emits = defineEmits();
  15. const state = reactive({
  16. imgList: [],
  17. // 相当于是set 与 get
  18. visible: useVModel(props, "modelValue", emits),
  19. });
  20. // 点击关闭的时候,连同小图一起关闭
  21. function close() {
  22. state.visible = false;
  23. }
  24. </script>
  25. <style lang="scss" scoped>
  26. </style>