可以通过访问系统剪切板实现,参考以下demo://设置剪贴板数据 export function SetPasteboardData() { let plainTextData = new unifiedDataChannel.UnifiedData(); let plainText = new unifiedDataChannel.PlainText(); plainText.details = { Key: 'test1234', Value: 'test1234', }; plainText.textContent = 'test1234'; plainText.abstract = 'test1234'; plainTextData.addRecord(plainText); let systemPasteboard: pasteboard.SystemPasteboard = pasteboard.getSystemPasteboard(); try { systemPasteboard.setUnifiedDataSync(plainTextData); console.info('tag, Succeeded in setting UnifiedData.'); } catch (err) { console.error('tag, Failed to set UnifiedData. Cause:' + err.message); }; } //获取剪贴板数据 export function GetPasteboardData() { let systemPasteboard: pasteboard.SystemPasteboard = pasteboard.getSystemPasteboard(); try { let result: unifiedDataChannel.UnifiedData = systemPasteboard.getUnifiedDataSync(); console.info('tag, Succeeded in getting UnifiedData.'); } catch (err) { console.error('tag, Failed to get UnifiedData. Cause:' + err.message); }; }剪贴板的API和示例请参考如下文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-pasteboard-V5
可以通过访问系统剪切板实现,参考以下demo:
剪贴板的API和示例请参考如下文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-pasteboard-V5