Alert

API 参考
confirmAlert
签名
例子
参数
名称
描述
类型
返回
类型
Alert.Options
例子
属性
名称
描述
类型
Alert.ActionOptions
属性
名称
描述
类型
Alert.ActionStyle
枚举成员
名称
值
最后更新于

最后更新于
async function confirmAlert(options: Alert.Options): Promise<boolean>;import { confirmAlert } from "@raycast/api";
export default async function Command() {
if (await confirmAlert({ title: "Are you sure?" })) {
console.log("confirmed");
// do something
} else {
console.log("canceled");
}
}import { Alert, confirmAlert } from "@raycast/api";
export default async function Command() {
const options: Alert.Options = {
title: "Finished cooking",
message: "Delicious pasta for lunch",
primaryAction: {
title: "Do something",
onAction: () => {
// while you can register a handler for an action, it's more elegant
// to use the `if (await confirmAlert(...)) { ... }` pattern
console.log("The alert action has been triggered");
},
},
};
await confirmAlert(options);
}