copy(i){ //i是下标
var text =document.getElementsByClassName("copyText")[i].innerText; //在需要复制文字加上class
var input = document.createElement('input');
input.setAttribute('id', 'copyInput');
input.setAttribute('value', text);
document.getElementsByTagName('body')[0].appendChild(input);
document.getElementById('copyInput').select();
if (document.execCommand('copy')) {
// alert('复制成功');
Toast.success('复制成功');
}
document.getElementById('copyInput').remove();
}
js复制功能实现
于 2021-11-01 11:05:26 首次发布