ant-design/components/avatar/demo/fallback.md
parabolazz 9b56ad86fb
docs: explain Avatar fallback strategy (#35415)
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.
2022-05-07 11:56:03 +08:00

670 B
Raw Blame History

order title debug
99
zh-CN en-US
图片不存在时 Fallback
true

zh-CN

图片不存在时,如果 src 本身是个 ReactElement会尝试回退到 src,否则尝试回退到 icon,最后回退到显示 children

en-US

图片不存在时,如果 src 本身是个 ReactElement会尝试回退到 src,否则尝试回退到 icon,最后回退到显示 children

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>
  </>
);