<script setup>
import { ref } from 'vue'
import defaultImg from '@/assets/cover.jpg'
const dialogVisible = ref(false)

const imgValue = ref()
// 组件对外暴露一个方法 open ，基于 open 传来的参数，区分添加还是编辑
const open = (imgUrl) => {
  imgValue.value = imgUrl
  console.log('img', imgUrl)

  dialogVisible.value = true
}
// 向外暴露
defineExpose({
  open
})

// const emit = defineEmits(['success'])
// emit('success')
</script>
<template>
  <el-dialog v-model="dialogVisible" draggable>
    <img
      :src="
        imgValue === null || imgValue === '' || imgValue === ' '
          ? defaultImg
          : imgValue
      "
      style="height: 100%; width: 100%"
      alt="图片加载失败"
    />
  </el-dialog>
</template>
