Skip to content

Commit 43a503f

Browse files
committed
feat: avatar add srcSet
1 parent 8eaf6da commit 43a503f

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

components/avatar/Avatar.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export default {
1919
default: 'default',
2020
},
2121
src: String,
22+
/** Srcset of image avatar */
23+
srcSet: String,
2224
icon: String,
2325
alt: String,
2426
loadError: Function,
@@ -71,7 +73,7 @@ export default {
7173
},
7274
render () {
7375
const {
74-
prefixCls, shape, size, src, icon, alt,
76+
prefixCls, shape, size, src, icon, alt, srcSet,
7577
} = this.$props
7678

7779
const { isImgExist, scale } = this.$data
@@ -101,6 +103,7 @@ export default {
101103
children = (
102104
<img
103105
src={src}
106+
srcSet={srcSet}
104107
onError={this.handleImgLoadError}
105108
alt={alt}
106109
/>

components/avatar/index.en-US.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
| shape | the shape of avatar | `circle` \| `square` | `circle` |
77
| size | the size of the avatar | number \| string: `large` `small` `default` | `default` |
88
| src | the address of the image for an image avatar | string | - |
9+
| srcSet | a list of sources to use for different screen resolutions | string | - |
910
| alt | This attribute defines the alternative text describing the image | string | - |
1011
| loadError | handler when img load error,return false to prevent default fallback behavior | () => boolean | - |
1112

components/avatar/index.zh-CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
| shape | 指定头像的形状 | Enum{ 'circle', 'square' } | `circle` |
77
| size | 设置头像的大小 | number \| Enum{ 'large', 'small', 'default' } | `default` |
88
| src | 图片类头像的资源地址 | string | - |
9+
| srcSet | 设置图片类头像响应式资源地址 | string | - |
910
| alt | 图像无法显示时的替代文本 | string | - |
1011
| loadError | 图片加载失败的事件,返回 false 会关闭组件默认的 fallback 行为 | () => boolean | - |
1112

0 commit comments

Comments
 (0)