Clipboard.js 实现点击复制
在开发过程中难免会遇到点击分享的需求,这里有两种实现方式: 第一种: 通过原生js 的方法用( 存在兼容性 ): document.execCommand( aCommandName, aShowDefaultUI, aValueArgument**)** 参数说明: aCommandName 命令的名称:常用的为"copy","cut"等; 注:“copy” 拷贝当前选中内容到剪贴板 “cut” 剪贴当前选中的文字并复制到剪贴板 aShowDefaultUI 是否展示用户界面,一般为 false; aValueArgument 默认为null; 返回值:Boolean 如果还是false 则表示还不能支持; html : < input type = " text " id = " copyVal " readonly value = " 被复制内容 " /> < button class = " copyBtn " > 点击复制 </ button > javascript: var copyBtn = document . getElementsByClassName ( 'copyBtn' ) [ 0 ] ; copyBtn . onclick = function ( ) { var copyVal = document . getElementById (