首页 > 其他 > 详细

Vue —— 复制文本

时间:2018-12-18 11:25:58      阅读:190      评论:0      收藏:0      [点我收藏+]
copyText() {
    const input = document.createElement("input");
    input.setAttribute("readonly", "readonly");
    input.setAttribute("value", "hello world");
    document.body.appendChild(input);
    input.setSelectionRange(0, 9999);
    if (document.execCommand("copy")) {
        document.execCommand("copy");
        console.log("复制成功");
    }
    document.body.removeChild(input);
}

链接:https://www.jb51.net/article/135605.htm

Vue —— 复制文本

原文:https://www.cnblogs.com/cnloop/p/10135928.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!