有没有办法可以复制到Node.js中的剪贴板?任何模块或想法是什么?我在桌面应用程序上使用Node.js. 希望这能解清为什么我希望它能够实现这一目标.
以下代码行在 chrome 升级到版本 74.0.3729.169(官方版本)(64 位)后用于工作并停止工作。现在,即使权限设置正确,我也会收到 DOMException。感谢您能否解释错误和解决方法。异常详情:
消息:文档不是重点名称:NotAllowedError 代码:0
navigator.permissions.query({ name: 'clipboard-read' }).then(result => {
// If permission to read the clipboard is granted or if the user will
// be prompted to allow it, we proceed.
if (result.state === 'granted' || result.state === 'prompt') {
navigator.clipboard.readText()
.then(text => {
//my code to handle paste
})
.catch(err => {
console.error('Failed to read clipboard contents: ', err);
});
Run Code Online (Sandbox Code Playgroud)