From 2fff73ab9d58d37d673edfc799573cf672e15773 Mon Sep 17 00:00:00 2001 From: anlyyao Date: Wed, 12 Oct 2022 16:44:02 +0800 Subject: [PATCH] fix(Image): use correct img tag load and error event name --- src/image/__test__/index.test.jsx | 10 +++++----- src/image/image.vue | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/image/__test__/index.test.jsx b/src/image/__test__/index.test.jsx index 08c252e76..8089e3003 100644 --- a/src/image/__test__/index.test.jsx +++ b/src/image/__test__/index.test.jsx @@ -24,12 +24,12 @@ describe('Image', () => { await nextTick(); const $image = wrapper.find(`.${name}__img`); expect(wrapper.find(`.${name}__status`).exists()).toBeTruthy(); - // 触发 IntersectionObserver , 但图片加载完成不会触发 Load 回调, + // 触发 IntersectionObserver , 但图片加载完成不会触发 load 回调, $image.trigger('resize'); await nextTick(); expect($image.attributes('src')).toBe(IMAGE); // 手动触发 图片加载完成的回调函数 - await $image.trigger('Load'); + await $image.trigger('load'); expect(wrapper.element).toMatchSnapshot(); expect(wrapper.find(`.${name}__status`).exists()).toBeFalsy(); }); @@ -108,7 +108,7 @@ describe('Image', () => { await nextTick(); const $image = wrapper.find(`.${name}__img`); // 手动触发 图片加载失败的回调函数 - await $image.trigger('Error'); + await $image.trigger('error'); expect(wrapper.find(`.${name}__status`).exists()).toBeTruthy(); // src = '',不会触发 error expect(onError).toBeCalledTimes(0); @@ -123,7 +123,7 @@ describe('Image', () => { await nextTick(); const $image = wrapper.find(`.${name}__img`); // 手动触发 图片加载失败的回调函数 - await $image.trigger('Error'); + await $image.trigger('error'); const status = wrapper.find(`.${name}__status`); expect(status.exists()).toBeTruthy(); expect(status.text()).toBe('加载失败'); @@ -137,7 +137,7 @@ describe('Image', () => { const $image = wrapper.find(`.${name}__img`); expect($image.attributes('src')).toBe(IMAGE); // 手动触发 图片加载完成的回调函数 - await $image.trigger('Load'); + await $image.trigger('load'); expect(onLoad).toBeCalledTimes(1); }); }); diff --git a/src/image/image.vue b/src/image/image.vue index d2dd9de92..9e80d2383 100644 --- a/src/image/image.vue +++ b/src/image/image.vue @@ -9,8 +9,8 @@ :style="imageStyles" :src="realSrc" :alt="alt" - @Load="handleImgLoadCompleted" - @Error="handleImgLoadError" + @load="handleImgLoadCompleted" + @error="handleImgLoadError" />