這是復(fù)制文本的代碼?
import {
? ? Clipboard
} from 'react-native';
?state = {
? ? ? ? ? ? text:'邀請(qǐng)碼1001'
? ?}
?//復(fù)制方法?
? copy =()?=> {
? ? ? ? Clipboard.setString(this.state.text);? ?
? }
? render()?{
? ? ? ? return(
? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? {this.state.text}
? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? 點(diǎn)擊復(fù)制到剪貼板
? ? ? ? )
? ? }
===============================================
其他頁面調(diào)用復(fù)制的文本
import {
? ? Clipboard
} from 'react-native';
componentDidMount(){
? ? this.getText()
}
//異步獲取剪貼板的內(nèi)容
? getText?= async?()?=> {
? ? var? str = await Clipboard.getString()弯洗;
? ? console.log(str)//邀請(qǐng)碼1001
? }