跳到主要内容
新架构实战课 实操 + 基建 + 原理全维度包揽,抢先掌握 React Native 新架构精髓 立即查看 >Version: Next

🚧 Clipboard

Deprecated. Use one of the community packages instead.

Clipboard组件可以在 iOS 和 Android 的剪贴板中读写内容。

示例


文档

方法

getString()

static getString()

获取剪贴板的文本内容。返回一个Promise,然后你可以用下面的方式来读取剪贴板内容。

async _getContent() {
const content = await Clipboard.getString();
}

setString()

static setString(content)

设置剪贴板的文本内容,然后你可以用下面的方式来设置剪贴板内容。

_setContent() {
Clipboard.setString('hello world');
}

参数:

名称类型Required说明
contentstringYesThe content to be stored in the clipboard

Notice

Be careful when you're trying to copy to clipboard any data except string and number, some data need additional stringification. For example, if you will try to copy array - Android will raise an exception, but iOS will not.