Clipboard.js clipboard.copy()在Meteor回调中无法正常工作

时间:2016-06-23 09:30:07

标签: javascript node.js meteor

当我在流星回调中使用clipboard.js中的clipboard.copy()时会出现错误:

Unable to copy. Perhaps it's not available in your browser?

我所说的方式是:

Meteor.call "create_course", @email, @id, (err,ret) ->
    clipboard.copy(ret)

服务器端create_course方法正常工作,如果我在回调之外使用clipboard.copy(“some text”),它可以正常工作。

查看clipboard.js文件后,问题来自document.execCommand("copy"),错误来自执行这部分软件包:

try {
     console.log(document.execCommand("copy"))
     if (document.execCommand("copy")) {
        // document.execCommand is synchronous: http://www.w3.org/TR/2015/WD-clipboard-apis-20150421/#integration-with-rich-text-editing-apis
        // So we can call resolve() back here.
            cleanup();
            resolve();
     }
     else {
        throw new Error("Unable to copy. Perhaps it's not available in your browser?");
     }

我希望能够将来自create_course回调的结果文本复制到剪贴板。

0 个答案:

没有答案