diff --git a/src/image/README.md b/src/image/README.md index 83ea8f509..d344bc191 100644 --- a/src/image/README.md +++ b/src/image/README.md @@ -77,6 +77,7 @@ Vue.use(Lazyload); | show-loading | Whether to show loading placeholder | _boolean_ | `true` | | error-icon `v2.4.2` | Error icon | _string_ | `photo-fail` | | loading-icon `v2.4.2` | Loading icon | _string_ | `photo` | +| icon-prefix `v2.10.12` | Icon className prefix | _string_ | `van-icon` | ### fit optional value diff --git a/src/image/README.zh-CN.md b/src/image/README.zh-CN.md index ca26e2797..a6bec222a 100644 --- a/src/image/README.zh-CN.md +++ b/src/image/README.zh-CN.md @@ -109,6 +109,7 @@ Vue.use(Lazyload); | show-loading | 是否展示图片加载中提示 | _boolean_ | `true` | | error-icon `v2.4.2` | 失败时提示的[图标名称](#/zh-CN/icon)或图片链接 | _string_ | `photo-fail` | | loading-icon `v2.4.2` | 加载时提示的[图标名称](#/zh-CN/icon)或图片链接 | _string_ | `photo` | +| icon-prefix `v2.10.12` | 图标类名前缀,同 Icon 组件的 [class-prefix 属性](#/zh-CN/icon#props) | _string_ | `van-icon` | ### 图片填充模式  diff --git a/src/image/index.js b/src/image/index.js index b1daea8ee..30993d464 100644 --- a/src/image/index.js +++ b/src/image/index.js @@ -13,6 +13,7 @@ export default createComponent({ height: [Number, String], radius: [Number, String], lazyLoad: Boolean, + iconPrefix: String, showError: { type: Boolean, default: true, @@ -117,7 +118,11 @@ export default createComponent({ return (
{this.slots('loading') || ( - + )}
); @@ -127,7 +132,11 @@ 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 bf6b22e39..6fae403fe 100644 --- a/src/image/test/__snapshots__/index.spec.js.snap +++ b/src/image/test/__snapshots__/index.spec.js.snap @@ -1,5 +1,19 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`apply icon-prefix prop to error-icon 1`] = ` +
+
+
+
+`; + +exports[`apply icon-prefix prop to loading-icon 1`] = ` +
+
+
+
+`; + exports[`default slot 1`] = `
diff --git a/src/image/test/index.spec.js b/src/image/test/index.spec.js index 28529a564..6599841d0 100644 --- a/src/image/test/index.spec.js +++ b/src/image/test/index.spec.js @@ -147,6 +147,31 @@ test('loading-icon prop', () => { expect(wrapper).toMatchSnapshot(); }); +test('apply icon-prefix prop to error-icon', () => { + const wrapper = mount(VanImage, { + propsData: { + errorIcon: 'error', + iconPrefix: 'my-icon', + src: 'https://img.yzcdn.cn/vant/cat.jpeg', + }, + }); + + wrapper.find('img').trigger('error'); + + expect(wrapper).toMatchSnapshot(); +}); + +test('apply icon-prefix prop to loading-icon', () => { + const wrapper = mount(VanImage, { + propsData: { + loadingIcon: 'success', + iconPrefix: 'my-icon', + }, + }); + + expect(wrapper).toMatchSnapshot(); +}); + test('radius prop', () => { const wrapper = mount(VanImage, { propsData: {