Result
带图标、说明和下一步操作的结果页。
Try again
We couldn't load this screen. Please check your connection and try again.
导入
“导入”部分import { Result, ResultButton } from "@pelagornis/page/components";示例
“示例”部分上方预览渲染的就是这个文件。复制到 src/components/ 即可开始使用。
import { Result, ResultButton } from "@pelagornis/page/components";
export default function ResultDemo() { return ( <Result variant="error" title="Try again" description="We couldn't load this screen. Please check your connection and try again." actions={<ResultButton>Try again</ResultButton>} /> );}在 MDX 中使用
“在 MDX 中使用”部分Result 由共享 React 状态的多个部分组成。写在 MDX 中的子节点会分别成为独立岛屿,彼此无法互通。请像上方示例一样在 .tsx 文件中组装,再导入该文件。
---title: Example---
import ResultExample from "../../components/ResultExample";
<ResultExample client:load />client:load 会在页面加载时水合该岛屿。页面靠下的内容可使用 client:visible。
在 Markdoc 中使用
“在 Markdoc 中使用”部分Markdoc 标签会渲染 Astro 组件,而该组件需要客户端状态。请用会水合示例的 .astro 文件包装,再把该文件注册为标签。
---import ResultExample from "../ResultExample";---
<ResultExample client:load />import { component, defineMarkdocConfig } from "@astrojs/markdoc/config";import starlightMarkdoc from "@astrojs/starlight-markdoc";import pageMarkdoc from "@pelagornis/page/markdoc";
export default defineMarkdocConfig({ extends: [starlightMarkdoc(), pageMarkdoc()], tags: { "result-example": { render: component("./src/components/markdoc/ResultExample.astro"), selfClosing: true, }, },});{% result-example /%}变体
“变体”部分各 variant prop 可接受的值。
| Prop | 取值 |
|---|---|
variant | success info warning error |
结构
“结构”部分组件各部分及其渲染的 data-refineui 角色。
| 部件 | 角色 |
|---|---|
root | result |
icon | result-icon |
title | result-title |
description | result-description |
actions | result-actions |
状态
“状态”部分组件会样式化的状态。组件状态通过 data 属性暴露。
键盘
“键盘”部分组件获得焦点时处理的按键。
参考
“参考”部分- 设计指南与令牌细节见 RefineUI · Result。
- 通用规则见 在 MDX 中使用 与 在 Markdoc 中使用。