HTML:
CSS:.item-r {
opacity: 0;
position: absolute;
left: -20000;
}
copy () {
const phone = document.getElementById('phone')
phone.innerHTML = '111'
this.selectText(phone)
document.execCommand('copy')
},
selectText (phone) {
if (document.selection) {
const range = document.body.createTextRange()
range.moveToElementText(phone)
range.select()
this.$toast('复制成功')
} else if (window.getSelection) {
const selection = window.getSelection()
const range = document.createRange()
selection.removeAllRanges()
range.selectNodeContents(phone)
selection.addRange(range)
this.$toast('复制成功')
}
}