Result结果

用于反馈一系列操作任务的处理结果。

何时使用

当有重要操作需告知用户处理结果,且反馈内容较为复杂时使用。

代码演示

Result结果 - 图1

Success

成功的结果。

  1. import { Result, Button } from 'antd';
  2. ReactDOM.render(
  3. <Result
  4. status="success"
  5. title="Successfully Purchased Cloud Server ECS!"
  6. subTitle="Order number: 2017182818828182881 Cloud server configuration takes 1-5 minutes, please wait."
  7. extra={[
  8. <Button type="primary" key="console">
  9. Go Console
  10. </Button>,
  11. <Button key="buy">Buy Again</Button>,
  12. ]}
  13. />,
  14. mountNode,
  15. );

Result结果 - 图2

Info

展示处理结果。

  1. import { Result, Button } from 'antd';
  2. ReactDOM.render(
  3. <Result
  4. title="Your operation has been executed"
  5. extra={
  6. <Button type="primary" key="console">
  7. Go Console
  8. </Button>
  9. }
  10. />,
  11. mountNode,
  12. );

Result结果 - 图3

Warning

警告类型的结果。

  1. import { Result, Button } from 'antd';
  2. ReactDOM.render(
  3. <Result
  4. status="warning"
  5. title="There are some problems with your operation."
  6. extra={
  7. <Button type="primary" key="console">
  8. Go Console
  9. </Button>
  10. }
  11. />,
  12. mountNode,
  13. );

Result结果 - 图4

403

你没有此页面的访问权限。

  1. import { Result, Button } from 'antd';
  2. ReactDOM.render(
  3. <Result
  4. status="403"
  5. title="403"
  6. subTitle="Sorry, you are not authorized to access this page."
  7. extra={<Button type="primary">Back Home</Button>}
  8. />,
  9. mountNode,
  10. );

Result结果 - 图5

404

此页面未找到。

  1. import { Result, Button } from 'antd';
  2. ReactDOM.render(
  3. <Result
  4. status="404"
  5. title="404"
  6. subTitle="Sorry, the page you visited does not exist."
  7. extra={<Button type="primary">Back Home</Button>}
  8. />,
  9. mountNode,
  10. );

Result结果 - 图6

500

服务器发生了错误。

  1. import { Result, Button } from 'antd';
  2. ReactDOM.render(
  3. <Result
  4. status="500"
  5. title="500"
  6. subTitle="Sorry, the server is wrong."
  7. extra={<Button type="primary">Back Home</Button>}
  8. />,
  9. mountNode,
  10. );

Result结果 - 图7

Error

复杂的错误反馈。

  1. import { Result, Button, Icon, Typography } from 'antd';
  2. const { Paragraph, Text } = Typography;
  3. ReactDOM.render(
  4. <Result
  5. status="error"
  6. title="Submission Failed"
  7. subTitle="Please check and modify the following information before resubmitting."
  8. extra={[
  9. <Button type="primary" key="console">
  10. Go Console
  11. </Button>,
  12. <Button key="buy">Buy Again</Button>,
  13. ]}
  14. >
  15. <div className="desc">
  16. <Paragraph>
  17. <Text
  18. strong
  19. style={{
  20. fontSize: 16,
  21. }}
  22. >
  23. The content you submitted has the following error:
  24. </Text>
  25. </Paragraph>
  26. <Paragraph>
  27. <Icon style={{ color: 'red' }} type="close-circle" /> Your account has been frozen{' '}
  28. <a>Thaw immediately &gt;</a>
  29. </Paragraph>
  30. <Paragraph>
  31. <Icon style={{ color: 'red' }} type="close-circle" /> Your account is not yet eligible to
  32. apply <a>Apply Unlock &gt;</a>
  33. </Paragraph>
  34. </div>
  35. </Result>,
  36. mountNode,
  37. );

Result结果 - 图8

自定义 icon

自定义 icon。

  1. import { Result, Icon, Button } from 'antd';
  2. ReactDOM.render(
  3. <Result
  4. icon={<Icon type="smile" theme="twoTone" />}
  5. title="Great, we have done all the operations!"
  6. extra={<Button type="primary">Next</Button>}
  7. />,
  8. mountNode,
  9. );

API

参数说明类型默认值版本
titletitle 文字ReactNode-3.20.0
subTitlesubTitle 文字ReactNode-3.20.0
status结果的状态,决定图标和颜色'success' | 'error' | 'info' | 'warning'| '404' | '403' | '500''info'3.20.0
icon自定义 iconstring | ReactNode-3.20.0
extra操作区ReactNode-3.20.0