UI弹出呈现
confirmationDialog
显示一组操作供用户选择。
confirmationDialog(options) 显示系统操作列表,在 iPhone 上从底部弹出。点击按钮后,先执行该按钮的 action,再调用 onDismiss。
import { Button, Modifier, useState } from "onescript/views"
function ShareButton() {
const [shown, setShown] = useState(false)
return (
<Button
action={() => setShown(true)}
modifier={Modifier.confirmationDialog({
title: "分享到",
titleVisibility: "visible",
isPresented: shown,
onDismiss: () => setShown(false),
actions: [
<Button action={() => share("messages")}>信息</Button>,
<Button action={() => share("mail")}>邮件</Button>,
<Button
role="cancel"
action={() => {}}
>
取消
</Button>,
],
})}
>
分享
</Button>
)
}| 参数 | 类型 | 说明 |
|---|---|---|
title | string | 标题。 |
titleVisibility | "automatic" | "visible" | "hidden" | 可选。标题是否显示,默认 "automatic"。 |
message | string | 可选。标题下方的说明文字。 |
isPresented | boolean | 是否显示。 |
onDismiss | () => void | 关闭时调用,需在其中把 isPresented 设为 false。 |
actions | ViewChild | 操作按钮。 |
actions 只接受标签为纯文本的 Button,且它们不能带 modifier。
How is this guide?
最后更新于