fix: 解决切换组件图片不会变动的问题

This commit is contained in:
奔跑的面条
2023-01-16 17:58:07 +08:00
parent f49a556953
commit 651bd976f3
6 changed files with 18 additions and 37 deletions
@@ -0,0 +1,3 @@
import ChartGlobImage from './index.vue'
export { ChartGlobImage }
@@ -0,0 +1,31 @@
<template>
<img class="list-img" v-lazy="imageInfo" alt="图表图片" />
</template>
<script setup lang="ts">
import { ref, PropType, watch } from 'vue'
import { fetchImages } from '@/packages'
import { ConfigType } from '@/packages/index.d'
const props = defineProps({
chartConfig: {
type: Object as PropType<ConfigType>,
required: true
}
})
const imageInfo = ref('')
// 获取图片
const fetchImageUrl = async () => {
imageInfo.value = await fetchImages(props.chartConfig)
}
watch(
() => props.chartConfig.key,
() => fetchImageUrl(),
{
immediate: true
}
)
</script>