当前位置:网站首页>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
边栏推荐
- OC to swift conditional compilation, marking, macro, log, version detection, expiration prompt
- Explanation and example application of the principle of logistic regression in machine learning
- Resolve the conflict between computed attribute and input blur event
- 编程哲学——自动加载、依赖注入与控制反转
- 博睿数据携手F5共同构建金融科技从代码到用户的全数据链DNA
- 2-Go变量操作
- Epoll's et, lt working mode -- example program
- 你还不知道责任链模式的使用场景吗?
- thinkphp5+数据大屏展示效果
- 抑郁症治疗的进展
猜你喜欢
How does eolink help telecommuting
PCIe X1 插槽的主要用途是什么?
[untitled]
中富金石财富班29800效果如何?与专业投资者同行让投资更简单
你還不知道責任鏈模式的使用場景嗎?
22年了你还不知道文件包含漏洞?
LeetCode162-寻找峰值-二分-数组
Want to be an architect? Tamping the foundation is the most important
LeetCode167-两数之和II-双指针-二分-数组-查找
Leetcode167 - sum of two numbers II - double pointer - bisection - array - Search
随机推荐
Using MATLAB programming to realize the steepest descent method to solve unconstrained optimization problems
Daily question - leetcode396 - rotation function - recursion
Leetcode165 compare version number double pointer string
Leetcode149 - maximum number of points on a line - Math - hash table
1n5408-asemi rectifier diode
Programming philosophy - automatic loading, dependency injection and control inversion
3、 Gradient descent solution θ
Difference between like and regexp
Want to be an architect? Tamping the foundation is the most important
LeetCode165-比较版本号-双指针-字符串
Flink DataStream 类型系统 TypeInformation
PCIe X1 插槽的主要用途是什么?
eolink 如何助力远程办公
SQL中HAVING和WHERE的区别
The art of automation
Leetcode167 - sum of two numbers II - double pointer - bisection - array - Search
免费在upic中设置OneDrive或Google Drive作为图床
LeetCode162-寻找峰值-二分-数组
Practice of unified storage technology of oppo data Lake
How to write the keywords in the cover and title? As we media, why is there no video playback