gpt4 book ai didi

javascript - 如何允许JavaScript execCommand (“paste”)在Electron中工作?

转载 作者:行者123 更新时间:2023-12-03 12:42:06 24 4
gpt4 key购买 nike

当用户单击屏幕上的特定按钮时,我想将剪贴板的内容粘贴到特定的文本字段中。

我目前使用的代码:

pasteSelectedTextFromClipboard() {
const input = this.$refs.input as any
input.focus()
document.execCommand("paste")
}

当我使用Google时,我发现在 Firefox中必须设置 user_pref("capability.policy.policynames", "allowclipboard");才能使此功能正常工作。我需要做什么才能使其在Electron中工作?

最佳答案

Electron 为剪贴板的所有操作公开了非常好的API

关于javascript - 如何允许JavaScript execCommand (“paste”)在Electron中工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59770054/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com