项目中经常遇到一键复制文本的操作,推荐一种原生方法
copyTitle(txt){
//原生copy方法
const input = document.createElement('input');
document.body.appendChild(input);
input.setAttribute('value', txt);
input.select();
if (document.execCommand('copy')) {
document.execCommand('copy');
alert('copy的内容为' + txt)
}
document.body.removeChild(input);
},