当前位置:网站首页>JS -- realize click Copy function
JS -- realize click Copy function
2022-04-23 14:55:00 【CaseyWei】
Select the copy
<template>
<el-button type="primary" plain @click="onCopy"> Copy </el-button>
</template>
<script>
export default {
methods:{
onCopy(){
document.execCommand("Copy"); // Execute browser copy command
this.$message({
message: ' Replication success ',
type: 'success'
});
}
}
}
</script>
Click replication
<template>
<el-button type="primary" plain @click="onCopy"> Copy </el-button>
</template>
<script>
export default {
methods:{
onCopy(){
const url = ' I am the content to be copied '
let oInput = document.createElement('input')
oInput.value = url
document.body.appendChild(oInput)
oInput.select() // Select object ;
document.execCommand('Copy') // Execute browser copy command
this.$message({
message: ' Replication success ',
type: 'success'
})
oInput.remove()
}
}
</script>
版权声明
本文为[CaseyWei]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231454092339.html
边栏推荐
猜你喜欢
中富金石财富班29800效果如何?与专业投资者同行让投资更简单
编程哲学——自动加载、依赖注入与控制反转
Is asemi ultrafast recovery diode interchangeable with Schottky diode
Sword finger offer II 019 Delete at most one character to get palindrome (simple)
PCIe X1 插槽的主要用途是什么?
3、 Gradient descent solution θ
在游戏世界组建一支AI团队,超参数的多智能体「大乱斗」开赛
LeetCode162-寻找峰值-二分-数组
Do (local scope), initializer, memory conflict, swift pointer, inout, unsafepointer, unsafebitcast, success
Detailed comparison between asemi three-phase rectifier bridge and single-phase rectifier bridge
随机推荐
Comment eolink facilite le télétravail
go基础 反射
免费在upic中设置OneDrive或Google Drive作为图床
Fill in the next right node pointer II of each node [classical hierarchy traversal | regarded as linked list]
【STC8G2K64S4】比较器介绍以及比较器掉电检测示例程序
[untitled]
OC 转 Swift 条件编译、标记、宏、 Log、 版本检测、过期提示
SQL中HAVING和WHERE的区别
Difference between like and regexp
LeetCode 练习——396. 旋转函数
Leetcode exercise - 396 Rotation function
The art of automation
在游戏世界组建一支AI团队,超参数的多智能体「大乱斗」开赛
nuxt项目:全局获取process.env信息
【NLP】HMM隐马尔可夫+维特比分词
压缩映射定理
Interviewer: let's talk about the process of class loading and the mechanism of class loading (parental delegation mechanism)
Swift protocol Association object resource name management multithreading GCD delay once
Chapter 7 of JVM series -- bytecode execution engine
Select receives both normal data and out of band data