gpt4 book ai didi

react-native - 复制文本后如何向用户显示 "text is copied"?

转载 作者:行者123 更新时间:2023-12-04 10:44:41 25 4
gpt4 key购买 nike

复制文本后如何向用户显示“文本已复制”?

const dataArray = [ { title: "Invoice Reference Number", content:QRCODE_SAMPLE.Irn } ];

<TouchableOpacity activeOpacity={1}
onPress={() => Clipboard.setString(QRCODE_SAMPLE.Irn)}>
<Accordion style={{paddingTop:10,paddingBottom:50,backgroundColor:'#E0DDDD'}}dataArray={dataArray} expanded={1}>
</Accordion>
</TouchableOpacity>

最佳答案

你可以这样做:

    import {ToastAndroid} from 'react-native';

创建此功能:
    onCopyPressed(){

Clipboard.setString(QRCODE_SAMPLE.Irn);
ToastAndroid.show('A pikachu appeared nearby !', ToastAndroid.SHORT);
}

并像这样调用该函数:
const dataArray = [ { title: "Invoice Reference Number", content:QRCODE_SAMPLE.Irn } ];
<TouchableOpacity activeOpacity={1}
onPress={this.onCopyPressed.bind(this)}>
<Accordion style={{paddingTop:10,paddingBottom:50,backgroundColor:'#E0DDDD'}}dataArray={dataArray} expanded={1}>
</Accordion>
</TouchableOpacity>

关于react-native - 复制文本后如何向用户显示 "text is copied"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59763491/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com