如何解决如何使Alert.alert消息能够复制和粘贴?
这是RN 0.63.2中的Alert.alert()
:
import { Alert } from "react-native";
Alert.alert(
'Alert Title','My Alert Msg',//<<==how to enable copy & paste on this message?
{ cancelable: false }
)
My Alert Msg
中有一些敏感信息,用户想要复制和粘贴。如何为用户复制和粘贴邮件?
解决方法
如果要从状态或Veriable设置消息文本,为什么不只是在警报中单击按钮功能,然后将警报中的Veriable或State内容复制到剪贴板?
Alert.alert('Alert Title',this.state.message,[ {text: 'Copy message',onPress: () => this.CopyAlertMessage(),style: 'cancel'},{text: 'close alert',onPress: () => this.closeAlert()},],{ cancelable: true});
然后具有您的功能
CopyAlertMessage = async () => {
Clipboard.setString(this.state.message)
}
只记得从react-native导入剪贴板
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。