From 03dfc05920e51c5c5d15bce4661b572135c2db89 Mon Sep 17 00:00:00 2001 From: liutao Date: Tue, 20 Aug 2024 14:41:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20img=20=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E7=BB=84=E4=BB=B6click=E4=BA=8B=E4=BB=B6=E5=A2=9E=E5=8A=A0mous?= =?UTF-8?q?eEvent=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/component/img.md | 2 +- .../wot-design-uni/components/wd-img/wd-img.vue | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/component/img.md b/docs/component/img.md index 7b15d1288..6d1cd8b0a 100644 --- a/docs/component/img.md +++ b/docs/component/img.md @@ -126,7 +126,7 @@ mode为小程序原生属性,参考[微信小程序image官方文档](https:// | 事件名称 | 说明 | 参数 | 最低版本 | | -------- | -------------------- | ----------------- | -------- | -| click | 点击事件 | - | - | +| click | 点击事件 | (event: MouseEvent) => void | - | | load | 当图片载入完毕时触发 | `{height, width}` | - | | error | 当错误发生时触发 | `{errMsg}` | - | diff --git a/src/uni_modules/wot-design-uni/components/wd-img/wd-img.vue b/src/uni_modules/wot-design-uni/components/wd-img/wd-img.vue index 73c95b673..6d8798c92 100644 --- a/src/uni_modules/wot-design-uni/components/wd-img/wd-img.vue +++ b/src/uni_modules/wot-design-uni/components/wd-img/wd-img.vue @@ -30,7 +30,11 @@ import { addUnit, isDef, objToStyle } from '../common/util' import { imgProps } from './types' const props = defineProps(imgProps) -const emit = defineEmits(['error', 'click', 'load']) +const emit = defineEmits<{ + (e: 'error', event: Event): void + (e: 'click', event: MouseEvent): void + (e: 'load', event: Event): void +}>() const rootStyle = computed(() => { const style: Record = {} @@ -57,13 +61,13 @@ function handleError(event: Event) { status.value = 'error' emit('error', event) } -function handleClick() { +function handleClick(event: MouseEvent) { if (props.enablePreview && props.src) { uni.previewImage({ urls: [props.src] }) } - emit('click') + emit('click', event) } function handleLoad(event: Event) { status.value = 'success'