English
Platform difference description for clipboard APIs
| App | H5 | 微信小程序 | 支付宝小程序 | 百度小程序 | 抖音小程序、飞书小程序 | QQ小程序 | 快手小程序 | 京东小程序 | 元服务 | 小红书小程序 |
|---|---|---|---|---|---|---|---|---|---|---|
| √ | √ | √ | √ | √ | √ | √ | √ | √ | √ | √ |
Set the contents of the system clipboard.
| HarmonyOS |
|---|
| HBuilderX 4.23 |
OBJECT parameter description
| Parameter Name | Type | Required | Description | Platform Difference Description |
|---|---|---|---|---|
| data | String | Yes | what needs to be set | |
| showToast | Boolean | No | Configure whether to pop up a prompt, the default popup prompt | App (3.2.13+), H5 (3.2.13+) |
| success | Function | No | Callback for successful interface call | |
| fail | Function | No | Callback function for interface call failure | |
| complete | Function | No | The callback function of the end of the interface call (the call will be executed if the call succeeds or fails) |
Example
uni.setClipboardData({
data: 'hello',
success: function () {
console.log('success');
}
});
Get the contents of the system clipboard.
| HarmonyOS |
|---|
| HBuilderX 4.23 |
OBJECT parameter description
| Parameter name | Type | Required | Instruction |
|---|---|---|---|
| success | Function | No | Callback for successful interface calling |
| fail | Function | No | Callback function for failed interface calling |
| complete | Function | No | Callback function for closed interface calling (available both for successful and failed calling) |
success return parameter description
| Parameter | Type | Instruction |
|---|---|---|
| data | String | Contents of the clipboard |
Example
uni.getClipboardData({
success: function (res) {
console.log(res.data);
}
});
HarmonyOS Next 平台使用时需要添加受限开放权限 ohos.permission.READ_PASTEBOARD