diff --git a/src/image/README.md b/src/image/README.md index b175729ab..db3b6c1cc 100644 --- a/src/image/README.md +++ b/src/image/README.md @@ -78,6 +78,7 @@ Vue.use(Lazyload); | lazy-load | Whether to enable lazy load,should register [Lazyload](#/en-US/lazyload) component | *boolean* | `false` | - | | show-error | Whether to show error placeholder | *boolean* | `true` | 2.0.9 | | show-loading | Whether to show loading placeholder | *boolean* | `true` | 2.0.9 | +| error-icon | Error icon | *string* | `warning-o` | 2.4.2 | | loading-icon | Loading icon | *string* | `photo-o` | 2.4.2 | ### fit optional value diff --git a/src/image/README.zh-CN.md b/src/image/README.zh-CN.md index 7c45f6cdf..8c888c9d5 100644 --- a/src/image/README.zh-CN.md +++ b/src/image/README.zh-CN.md @@ -104,6 +104,7 @@ Vue.use(Image); | lazy-load | 是否开启图片懒加载,须配合 [Lazyload](#/zh-CN/lazyload) 组件使用 | *boolean* | `false` | - | | show-error | 是否展示图片加载失败提示 | *boolean* | `true` | 2.0.9 | | show-loading | 是否展示图片加载中提示 | *boolean* | `true` | 2.0.9 | +| error-icon | 失败时提示的图标名称或图片链接,可选值见 [Icon 组件](#/zh-CN/icon) | *string* | `warning-o` | 2.4.2 | | loading-icon | 加载时提示的图标名称或图片链接,可选值见 [Icon 组件](#/zh-CN/icon) | *string* | `photo-o` | 2.4.2 | ### 图片填充模式 diff --git a/src/image/index.js b/src/image/index.js index 90dca3bd5..10adb82d5 100644 --- a/src/image/index.js +++ b/src/image/index.js @@ -21,6 +21,10 @@ export default createComponent({ type: Boolean, default: true }, + errorIcon: { + type: String, + default: 'warning-o' + }, loadingIcon: { type: String, default: 'photo-o' @@ -123,7 +127,7 @@ export default createComponent({ return (
{this.slots('error') || ( - + )}
); diff --git a/src/image/test/__snapshots__/index.spec.js.snap b/src/image/test/__snapshots__/index.spec.js.snap index f06652b5a..4dbffdaac 100644 --- a/src/image/test/__snapshots__/index.spec.js.snap +++ b/src/image/test/__snapshots__/index.spec.js.snap @@ -1,5 +1,12 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`error-icon prop 1`] = ` +
+
+
+
+`; + exports[`lazy load 1`] = `
diff --git a/src/image/test/index.spec.js b/src/image/test/index.spec.js index e60544f6f..2f7055375 100644 --- a/src/image/test/index.spec.js +++ b/src/image/test/index.spec.js @@ -125,6 +125,19 @@ test('show-error prop', () => { expect(wrapper).toMatchSnapshot(); }); +test('error-icon prop', () => { + const wrapper = mount(Image, { + propsData: { + errorIcon: 'error', + src: 'https://img.yzcdn.cn/vant/cat.jpeg' + } + }); + + wrapper.find('img').trigger('error'); + + expect(wrapper).toMatchSnapshot(); +}); + test('loading-icon prop', () => { const wrapper = mount(Image, { propsData: {