JS 原生实现 Safari 浏览器下的复制
var btn = document.querySelector('#btn');
btn.addEventListener('click',function(){
var 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);
});