js复制 document.execcommand

  • Post author:
  • Post category:其他



因为document.execcommand已弃用 所以使用下面方法

navigator.clipboard.writeText(String('文本')).then(function () {
        /* clipboard successfully set */
    }, function () {
        /* clipboard write failed */
    });

浏览器兼容

在这里插入图片描述



版权声明:本文为weixin_55666792原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。