mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-23 01:45:05 +08:00
Merge branch 'tmp_pr' into feature
This commit is contained in:
commit
73fd819322
@ -14,5 +14,6 @@ Avatars can be used to represent people or objects. It supports images, `Icon`s,
|
||||
| shape | the shape of avatar | `circle` \| `square` | `circle` |
|
||||
| size | the size of the avatar | number \| string: `large` `small` `default` | `default` |
|
||||
| src | the address of the image for an image avatar | string | - |
|
||||
| srcSet | a list of sources to use for different screen resolutions | string | - |
|
||||
| alt | This attribute defines the alternative text describing the image | string | - |
|
||||
| onError | handler when img load error,return false to prevent default fallback behavior | () => boolean | - |
|
||||
|
@ -13,6 +13,8 @@ export interface AvatarProps {
|
||||
size?: 'large' | 'small' | 'default' | number;
|
||||
/** Src of image avatar */
|
||||
src?: string;
|
||||
/** Srcset of image avatar */
|
||||
srcSet?: string;
|
||||
/** Type of the Icon to be used in avatar */
|
||||
icon?: string;
|
||||
style?: React.CSSProperties;
|
||||
@ -88,7 +90,7 @@ export default class Avatar extends React.Component<AvatarProps, AvatarState> {
|
||||
|
||||
render() {
|
||||
const {
|
||||
prefixCls, shape, size, src, icon, className, alt, ...others
|
||||
prefixCls, shape, size, src, srcSet, icon, className, alt, ...others
|
||||
} = this.props;
|
||||
|
||||
const { isImgExist, scale } = this.state;
|
||||
@ -116,6 +118,7 @@ export default class Avatar extends React.Component<AvatarProps, AvatarState> {
|
||||
children = (
|
||||
<img
|
||||
src={src}
|
||||
srcSet={srcSet}
|
||||
onError={this.handleImgLoadError}
|
||||
alt={alt}
|
||||
/>
|
||||
|
@ -19,5 +19,6 @@ title: Avatar
|
||||
| shape | 指定头像的形状 | Enum{ 'circle', 'square' } | `circle` |
|
||||
| size | 设置头像的大小 | number \| Enum{ 'large', 'small', 'default' } | `default` |
|
||||
| src | 图片类头像的资源地址 | string | - |
|
||||
| srcSet | 设置图片类头像响应式资源地址 | string | - |
|
||||
| alt | 图像无法显示时的替代文本 | string | - |
|
||||
| onError | 图片加载失败的事件,返回 false 会关闭组件默认的 fallback 行为 | () => boolean | - |
|
||||
|
Loading…
Reference in New Issue
Block a user