2020-07-26 16:53:50 +08:00
|
|
|
|
---
|
|
|
|
|
order: 99
|
|
|
|
|
title:
|
|
|
|
|
zh-CN: 图片不存在时
|
|
|
|
|
en-US: Fallback
|
|
|
|
|
debug: true
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
2022-05-07 11:56:03 +08:00
|
|
|
|
图片不存在时,如果 `src` 本身是个 ReactElement,会尝试回退到 `src`,否则尝试回退到 `icon`,最后回退到显示 `children`。
|
2020-07-26 16:53:50 +08:00
|
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
2022-05-07 11:56:03 +08:00
|
|
|
|
图片不存在时,如果 `src` 本身是个 ReactElement,会尝试回退到 `src`,否则尝试回退到 `icon`,最后回退到显示 `children`。
|
2020-07-26 16:53:50 +08:00
|
|
|
|
|
|
|
|
|
```tsx
|
|
|
|
|
import { Avatar } from 'antd';
|
2022-05-23 14:37:16 +08:00
|
|
|
|
import React from 'react';
|
2020-07-26 16:53:50 +08:00
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
|
const App: React.FC = () => (
|
2020-07-26 16:53:50 +08:00
|
|
|
|
<>
|
2020-08-06 14:32:13 +08:00
|
|
|
|
<Avatar shape="circle" src="http://abc.com/not-exist.jpg">
|
2020-07-26 16:53:50 +08:00
|
|
|
|
A
|
|
|
|
|
</Avatar>
|
2020-08-06 14:32:13 +08:00
|
|
|
|
<Avatar shape="circle" src="http://abc.com/not-exist.jpg">
|
2020-07-26 16:53:50 +08:00
|
|
|
|
ABC
|
|
|
|
|
</Avatar>
|
2022-04-03 23:27:45 +08:00
|
|
|
|
</>
|
2020-07-26 16:53:50 +08:00
|
|
|
|
);
|
2022-05-19 09:46:26 +08:00
|
|
|
|
|
|
|
|
|
export default App;
|
2020-07-26 16:53:50 +08:00
|
|
|
|
```
|