React Native Expo项目,复制文本到剪切板

装包:

npx expo install expo-clipboard

 

import * as Clipboard from 'expo-clipboard'

  const handleCopy = async (text) => {
    await Clipboard.setStringAsync(text)

    Toast.show('复制成功', {
      duration: 3000,
      position: Toast.positions.CENTER,
    })
  }

参考链接:

https://docs.expo.dev/versions/latest/sdk/clipboard/

https://www.npmjs.com/package/expo-clipboard 

https://chat.xutongbao.top/

 

posted @ 2023-08-14 14:00  徐同保  阅读(15)  评论(0编辑  收藏  举报  来源