md
This commit is contained in:
parent
7b8a9389d1
commit
e112a14366
@ -833,10 +833,32 @@ export default {
|
|||||||
handleCopySelect(event) {
|
handleCopySelect(event) {
|
||||||
this.contextVisible=false;
|
this.contextVisible=false;
|
||||||
if(this.currentSelectStr){
|
if(this.currentSelectStr){
|
||||||
navigator.clipboard.writeText(this.currentSelectStr).then(() => {
|
|
||||||
this.$message({message: '复制成功', type:'success'})//提示
|
|
||||||
this.currentSelectStr=null;
|
if (navigator.clipboard && window.isSecureContext) {
|
||||||
});
|
// navigator clipboard 向剪贴板写文本
|
||||||
|
this.$message.success('复制成功')
|
||||||
|
return navigator.clipboard.writeText(this.currentSelectStr)
|
||||||
|
} else {
|
||||||
|
// 创建text area
|
||||||
|
const textArea = document.createElement('textarea')
|
||||||
|
textArea.value = this.currentSelectStr
|
||||||
|
// 使text area不在viewport,同时设置不可见
|
||||||
|
document.body.appendChild(textArea)
|
||||||
|
textArea.focus()
|
||||||
|
textArea.select()
|
||||||
|
this.$message.success('复制成功')
|
||||||
|
return new Promise((res, rej) => {
|
||||||
|
// 执行复制命令并移除文本框
|
||||||
|
document.execCommand('copy') ? res() : rej()
|
||||||
|
textArea.remove()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// navigator.clipboard.writeText(this.currentSelectStr).then(() => {
|
||||||
|
// this.$message({message: '复制成功', type:'success'})//提示
|
||||||
|
// this.currentSelectStr=null;
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 选择整行
|
// 选择整行
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user