📌  相关文章
📜  navigator.clipboard.writetext 不起作用 - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:45.134000             🧑  作者: Mango

代码示例1
$scope.CopyToClipBoard = function (text) {        
    if (navigator.clipboard != undefined) {//Chrome
        navigator.clipboard.writeText(text).then(function () {
            console.log('Async: Copying to clipboard was successful!');
        }, function (err) {
            console.error('Async: Could not copy text: ', err);
        });
    }
    else if(window.clipboardData) { // Internet Explorer
        window.clipboardData.setData("Text", text);
    }
};