跳至主内容
版本:0.78

分享

非官方测试版翻译

本页面由 PageTurner AI 翻译(测试版)。未经项目官方认可。 发现错误? 报告问题 →

示例

参考

方法

share()

tsx
static share(content: ShareContent, options?: ShareOptions);

打开用于分享文本内容的对话框。

在 iOS 中,该方法返回一个 Promise,该 Promise 将传入一个包含 actionactivityType 的对象。如果用户关闭了对话框,Promise 仍会被解析为 action 值为 Share.dismissedAction 的对象,其他键值均为 undefined。请注意某些分享选项在 iOS 模拟器上不会显示或正常工作。

在 Android 中,该方法返回的 Promise 总是会被解析为 action 值为 Share.sharedAction 的对象。

属性:

NameTypeDescription
content
Required
objectmessage - a message to share
url - a URL to share
iOS

title - title of the message
Android

At least one of url and message is required.
optionsobjectdialogTitle
Android

excludedActivityTypes
iOS

subject - a subject to share via email
iOS

tintColor
iOS

anchor - the node to which the action sheet should be anchored (used for iPad)
iOS

属性

sharedAction

tsx
static sharedAction: 'sharedAction';

表示内容已成功分享。


dismissedAction
iOS

tsx
static dismissedAction: 'dismissedAction';

表示对话框已被关闭。