The clipboard APIs allow you to read from and write to the system clipboard, enabling copy and paste functionality within your mini program.
Retrieves the current content of the clipboard.
my.getClipboard({
success: (res) => {
my.alert({
content: res.text
});
},
});
| Property | Type | Required | Description |
|---|---|---|---|
success | Function | No | Callback function upon call success. |
fail | Function | No | Callback function upon call failure. |
complete | Function | No | Callback function upon call completion (to be executed upon either call success or failure). |
| Property | Type | Description |
|---|---|---|
text | String | Clipboard content. |
Sets text content to the clipboard.
my.setClipboard({
text: 'copy content',
success: () => {
my.alert({
content: 'Copied successfully'
});
},
});
| Property | Type | Required | Description |
|---|---|---|---|
text | String | Yes | The text content to copy to clipboard. |
success | Function | No | Callback function upon call success. |
fail | Function | No | Callback function upon call failure. |
complete | Function | No | Callback function upon call completion (to be executed upon either call success or failure). |
my.setClipboard overwrites any existing clipboard contentmy.getClipboard retrieves text content only