2017-11-08 00:34:50 +00:00
|
|
|
---
|
|
|
|
id: clipboard
|
|
|
|
title: Clipboard
|
|
|
|
layout: docs
|
|
|
|
category: APIs
|
|
|
|
permalink: docs/clipboard.html
|
|
|
|
next: datepickerandroid
|
|
|
|
previous: cameraroll
|
|
|
|
---
|
|
|
|
|
|
|
|
`Clipboard` gives you an interface for setting and getting content from Clipboard on both iOS and Android
|
|
|
|
|
|
|
|
|
|
|
|
### Methods
|
|
|
|
|
|
|
|
- [`getString`](docs/clipboard.html#getstring)
|
|
|
|
- [`setString`](docs/clipboard.html#setstring)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
# Reference
|
|
|
|
|
|
|
|
## Methods
|
|
|
|
|
|
|
|
### `getString()`
|
|
|
|
|
|
|
|
```javascript
|
2017-11-09 17:47:50 +00:00
|
|
|
Clipboard.getString()
|
2017-11-08 00:34:50 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
Get content of string type, this method returns a `Promise`, so you can use following code to get clipboard content
|
|
|
|
```javascript
|
|
|
|
async _getContent() {
|
|
|
|
var content = await Clipboard.getString();
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
### `setString()`
|
|
|
|
|
|
|
|
```javascript
|
2017-11-09 17:47:50 +00:00
|
|
|
Clipboard.setString(content)
|
2017-11-08 00:34:50 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
|
2017-11-09 17:47:50 +00:00
|
|
|
Set content of string type. You can use following code to set clipboard content:
|
|
|
|
|
2017-11-08 00:34:50 +00:00
|
|
|
```javascript
|
|
|
|
_setContent() {
|
|
|
|
Clipboard.setString('hello world');
|
|
|
|
}
|
|
|
|
```
|
2017-11-09 17:47:50 +00:00
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
| Name | Type | Required | Description |
|
|
|
|
| - | - | - | - |
|
|
|
|
| content | string | yes | The content to be stored in the clipboard. |
|
2017-11-08 00:34:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|