ReactNative开发——Clipboard
Clipboard
组件可以在iOS和Android的剪贴板中读写内容
示例
class ClipboardView extends Component {
state = {
textFormClipboard: ''
}
render() {
return (
<View style={{justifyContent: 'flex-start'}}> <Text > {this.state.textFormClipboard} </Text> <Text onPress={() => { // 向剪贴板写入数据 Clipboard.setString('AAA') }}> 点击将'AAA'赋值到剪贴盘 </Text> <Text onPress={() => { //从剪贴盘读数据 Clipboard.getString().then((text => this.setState({textFormClipboard: text}))) .catch(error => console.error(error)); }}> 点击粘贴 </Text> </View> ); } }