js一键复制
作者:
无题syl | 来源:发表于
2020-10-09 14:09 被阅读0次
点击按钮 实现一键复制
async copy() {
let { data } = await this.$api.getUnSubmitStuList({
taskID: this.objectId,
})
if (data.status == 1) {
let text = document.createElement('textarea') //如果内容里有空格 要用多文本标签 用input标签不行
//text.setAttribute('readonly', 'readonly')
text.value=data.data
document.body.appendChild(text)
text.select()
if (document.execCommand('copy')) {
document.execCommand('copy')
this.$alert.success('复制成功')
}
document.body.removeChild(text)
//console.log(data.data)
}
},
本文标题:js一键复制
本文链接:https://www.haomeiwen.com/subject/akelpktx.html
网友评论