案例
handleCopy(row) {
var textValue = document.createElement('textarea');
textValue.setAttribute('readonly', 'readonly'); //设置只读属性防止手机上弹出软键盘
textValue.value = row.formatValue //上面selectText函数返回值赋给textarea的value
document.body.appendChild(textValue); //将textarea添加为body子元素
textValue.select();
document.execCommand('copy');
document.body.removeChild(textValue);//移除DOM元素
this.$DIYMessage.success("复制成功")
},
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10