mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-12 07:09:55 +08:00
9b56ad86fb
The original description was unclear, incomplete, and confusing, requiring a look at the code to understand it, so I revised it to a more understandable version.
31 lines
670 B
Markdown
31 lines
670 B
Markdown
---
|
||
order: 99
|
||
title:
|
||
zh-CN: 图片不存在时
|
||
en-US: Fallback
|
||
debug: true
|
||
---
|
||
|
||
## zh-CN
|
||
|
||
图片不存在时,如果 `src` 本身是个 ReactElement,会尝试回退到 `src`,否则尝试回退到 `icon`,最后回退到显示 `children`。
|
||
|
||
## en-US
|
||
|
||
图片不存在时,如果 `src` 本身是个 ReactElement,会尝试回退到 `src`,否则尝试回退到 `icon`,最后回退到显示 `children`。
|
||
|
||
```tsx
|
||
import { Avatar } from 'antd';
|
||
|
||
export default () => (
|
||
<>
|
||
<Avatar shape="circle" src="http://abc.com/not-exist.jpg">
|
||
A
|
||
</Avatar>
|
||
<Avatar shape="circle" src="http://abc.com/not-exist.jpg">
|
||
ABC
|
||
</Avatar>
|
||
</>
|
||
);
|
||
```
|