中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
如何向当前剪贴板内容中添加一条条目?
微信扫码分享
import pasteboard from '@ohos.pasteboard'; //获取剪贴板内容对象实例 let pasteData: pasteboard.PasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, 'dataability:///com.example.myapplication1/user.txt'); let textRecord: pasteboard.PasteDataRecord = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, 'hello'); let html: string = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>"; let htmlRecord: pasteboard.PasteDataRecord = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_HTML, html); //插入一条文本内容条目 pasteData.addRecord(textRecord); //插入一条html内容条目 pasteData.addRecord(htmlRecord);