Result结果 - 图1

Result 结果

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

何时使用

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

代码演示

Result结果 - 图2

Success

成功的结果。

  1. <template>
  2. <a-result
  3. status="success"
  4. title="Successfully Purchased Cloud Server ECS!"
  5. sub-title="Order number: 2017182818828182881 Cloud server configuration takes 1-5 minutes, please wait."
  6. >
  7. <template #extra>
  8. <a-button key="console" type="primary">Go Console</a-button>
  9. <a-button key="buy">Buy Again</a-button>
  10. </template>
  11. </a-result>
  12. </template>

Result结果 - 图3

Info

展示处理结果。

  1. <template>
  2. <a-result title="Your operation has been executed">
  3. <template #extra>
  4. <a-button key="console" type="primary">Go Console</a-button>
  5. </template>
  6. </a-result>
  7. </template>

Result结果 - 图4

Warning

警告类型的结果。

  1. <template>
  2. <a-result status="warning" title="There are some problems with your operation.">
  3. <template #extra>
  4. <a-button key="console" type="primary">Go Console</a-button>
  5. </template>
  6. </a-result>
  7. </template>

Result结果 - 图5

403

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

  1. <template>
  2. <a-result status="403" title="403" sub-title="Sorry, you are not authorized to access this page.">
  3. <template #extra>
  4. <a-button type="primary">Back Home</a-button>
  5. </template>
  6. </a-result>
  7. </template>

Result结果 - 图6

404

此页面未找到。

  1. <template>
  2. <a-result status="404" title="404" sub-title="Sorry, the page you visited does not exist.">
  3. <template #extra>
  4. <a-button type="primary">Back Home</a-button>
  5. </template>
  6. </a-result>
  7. </template>

Result结果 - 图7

500

服务器发生了错误。

  1. <template>
  2. <a-result status="500" title="500" sub-title="Sorry, the server is wrong.">
  3. <template #extra>
  4. <a-button type="primary">Back Home</a-button>
  5. </template>
  6. </a-result>
  7. </template>

Result结果 - 图8

Error

复杂的错误反馈。

  1. <template>
  2. <a-result
  3. status="error"
  4. title="Submission Failed"
  5. sub-title="Please check and modify the following information before resubmitting."
  6. >
  7. <template #extra>
  8. <a-button key="console" type="primary">Go Console</a-button>
  9. <a-button key="buy">Buy Again</a-button>
  10. </template>
  11. <div class="desc">
  12. <p style="font-size: 16px">
  13. <strong>The content you submitted has the following error:</strong>
  14. </p>
  15. <p>
  16. <close-circle-outlined :style="{ color: 'red' }" />
  17. Your account has been frozen
  18. <a>Thaw immediately &gt;</a>
  19. </p>
  20. <p>
  21. <close-circle-outlined :style="{ color: 'red' }" />
  22. Your account is not yet eligible to apply
  23. <a>Apply Unlock &gt;</a>
  24. </p>
  25. </div>
  26. </a-result>
  27. </template>
  28. <script lang="ts">
  29. import { CloseCircleOutlined } from '@ant-design/icons-vue';
  30. import { defineComponent } from 'vue';
  31. export default defineComponent({
  32. components: {
  33. CloseCircleOutlined,
  34. },
  35. });
  36. </script>
  37. <style scoped>
  38. .desc p {
  39. margin-bottom: 1em;
  40. }
  41. </style>

Result结果 - 图9

自定义 icon

自定义 icon。

  1. <template>
  2. <a-result title="Great, we have done all the operations!">
  3. <template #icon>
  4. <smile-twoTone />
  5. </template>
  6. <template #extra>
  7. <a-button type="primary">Next</a-button>
  8. </template>
  9. </a-result>
  10. </template>
  11. <script lang="ts">
  12. import { SmileTwoTone } from '@ant-design/icons-vue';
  13. import { defineComponent } from 'vue';
  14. export default defineComponent({
  15. components: {
  16. SmileTwoTone,
  17. },
  18. });
  19. </script>

API

参数说明类型默认值
titletitle 文字string | VNode | #title-
subTitlesubTitle 文字string | VNode | #subTitle-
status结果的状态,决定图标和颜色‘success’ | ‘error’ | ‘info’ | ‘warning’| ‘404’ | ‘403’ | ‘500’‘info’
icon自定义 icon#icon-
extra操作区#extra-