feat(image): add "load" event 图片组件添加 “load” 事件 #8006
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
onLoad
事件在某些情况下是需要的,比如:v-if
控制,在onLoad
里设置为 true;onLoad
里设置 loading 为 false。(目前
4.2.6
版本的a-image
的@load="onLoad"
事件是不生效的)复现demo本次修改,移除
watch
监听 img 是因为:ant-design-vue/components/vc-image/src/Image.tsx
应该改为:
img
标签的 onLoad 事件基本能满足大部分情况。如果一定要的话,我会改为下面这种,为了满足
onLoad
的 event 参数:(但是会触发两次
emit('load', e)
事件,需要再添加额外判断来实现只触发一次)