📌  相关文章
📜  node.js 复制到剪贴板 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:47.188000             🧑  作者: Mango

代码示例2
// Copy to clipboard in node.js
const child_process = require('child_process')

// This uses an external application for clipboard access, so fill it in here
// Some options: pbcopy (macOS), xclip (Linux or anywhere with Xlib)
const COPY_APP = 'xclip'
function copy(data, encoding='utf8') {
  const proc = child_process.spawn(COPY_APP)
  proc.stdin.write(data, {encoding})
  proc.stdin.end()
}