mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 11:10:01 +08:00
avatar img add "alt" prop (#10798)
This commit is contained in:
parent
e51b043737
commit
2025a10a06
@ -14,3 +14,4 @@ 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 | `large` \| `small` \| `default` | `default` |
|
||||
| src | the address of the image for an image avatar | string | - |
|
||||
| alt | This attribute defines the alternative text describing the image | string | - |
|
@ -16,6 +16,7 @@ export interface AvatarProps {
|
||||
prefixCls?: string;
|
||||
className?: string;
|
||||
children?: any;
|
||||
alt?: string;
|
||||
}
|
||||
|
||||
export interface AvatarState {
|
||||
@ -75,7 +76,7 @@ export default class Avatar extends React.Component<AvatarProps, AvatarState> {
|
||||
|
||||
render() {
|
||||
const {
|
||||
prefixCls, shape, size, src, icon, className, ...others
|
||||
prefixCls, shape, size, src, icon, className, alt, ...others
|
||||
} = this.props;
|
||||
|
||||
const sizeCls = classNames({
|
||||
@ -95,6 +96,7 @@ export default class Avatar extends React.Component<AvatarProps, AvatarState> {
|
||||
<img
|
||||
src={src}
|
||||
onError={this.handleImgLoadError}
|
||||
alt={alt}
|
||||
/>
|
||||
);
|
||||
} else if (icon) {
|
||||
|
@ -15,3 +15,4 @@ title: Avatar
|
||||
| shape | 指定头像的形状 | Enum{ 'circle', 'square' } | `circle` |
|
||||
| size | 设置头像的大小 | Enum{ 'large', 'small', 'default' } | `default` |
|
||||
| src | 图片类头像的资源地址 | string | - |
|
||||
| alt | 图像无法显示时的替代文本 | string | - |
|
||||
|
Loading…
Reference in New Issue
Block a user