以下是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
中有用户想要复制和粘贴的敏感信息。如何使用户可以复制和粘贴消息?
发布于 2020-10-22 03:59:46
如果你从一个状态或可验证的状态设置消息文本,为什么不调用一个函数,点击警告中的按钮,并让它将可验证或状态的内容复制到剪贴板?
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导入剪贴板
https://stackoverflow.com/questions/64469651
复制相似问题