JS不使用插件实现复制功能

/**
   利用 navigator.clipboard.writeText() 方法
   返回值是一个promise对象  
*/
for example:

const copyPromise = navigator.clipboard.writeText(value);
copyPromise.then(() => {
    alert('已复制');
}).catch(err => {
    alert('复制失败');
});

 

posted @ 2023-02-09 13:19  Mr_R  阅读(20)  评论(0编辑  收藏  举报