W3Cschool
恭喜您成為首批注冊用戶
獲得88經驗值獎勵
clipboard
模塊提供方法來供復制和粘貼操作 . 下面例子展示了如何將一個字符串寫道 clipboard 上:
const clipboard = require('electron').clipboard;
clipboard.writeText('Example String');
在 X Window 系統(tǒng)上, 有一個可選的 clipboard. 你可以為每個方法使用 selection
來控制它:
clipboard.writeText('Example String', 'selection');
console.log(clipboard.readText('selection'));
clipboard
模塊有以下方法:
注意: 測試 APIs 已經標明,并且在將來會被刪除 .
clipboard.readText([type])
type
String (可選)以純文本形式從 clipboard 返回內容 .
clipboard.writeText(text[, type])
text
Stringtype
String (可選)以純文本形式向 clipboard 添加內容 .
clipboard.readHtml([type])
type
String (可選)返回 clipboard 中的標記內容.
clipboard.writeHtml(markup[, type])
markup
Stringtype
String (可選)向 clipboard 添加 markup
內容 .
clipboard.readImage([type])
type
String (可選)從 clipboard 中返回 NativeImage 內容.
clipboard.writeImage(image[, type])
image
NativeImagetype
String (可選)向 clipboard 中寫入 image
.
clipboard.readRtf([type])
type
String (可選)從 clipboard 中返回 RTF 內容.
clipboard.writeRtf(text[, type])
text
Stringtype
String (可選)向 clipboard 中寫入 RTF 格式的 text
.
clipboard.clear([type])
type
String (可選)清空 clipboard 內容.
clipboard.availableFormats([type])
type
String (可選)返回 clipboard 支持的格式數(shù)組 .
clipboard.has(data[, type])
Experimentaldata
Stringtype
String (可選)返回 clipboard 是否支持指定 data
的格式.
console.log(clipboard.has('<p>selection</p>'));
clipboard.read(data[, type])
Experimentaldata
Stringtype
String (可選)讀取 clipboard 的 data
.
clipboard.write(data[, type])
data
Objecttext
Stringhtml
Stringimage
NativeImagetype
String (可選)clipboard.write({text: 'test', html: "<b>test</b>"});
向 clipboard 寫入 data
.
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: