当前位置:网站首页>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
边栏推荐
- 8.3 language model and data set
- MySQL error packet out of order
- 帧同步 实现
- LeetCode153-寻找旋转排序数组中的最小值-数组-二分查找
- When splicing HQL, the new field does not appear in the construction method
- 【无标题】
- PCIe X1 插槽的主要用途是什么?
- 【STC8G2K64S4】比较器介绍以及比较器掉电检测示例程序
- Detailed analysis of SQL combat of Niuke database (26-30)
- OPPO数据湖统一存储技术实践
猜你喜欢
Leetcode153 - find the minimum value in the rotation sort array - array - binary search
LeetCode 练习——396. 旋转函数
分享 20 个不容错过的 ES6 的技巧
[NLP] HMM hidden Markov + Viterbi word segmentation
Share 20 tips for ES6 that should not be missed
Introduction to Arduino for esp8266 serial port function
【无标题】
MySQL报错packet out of order
How to upload large files quickly?
qt之.pro文件详解
随机推荐
[detailed explanation of factory mode] factory method mode
成都控制板设计提供_算是详细了_单片机程序头文件的定义、编写及引用介绍
[servlet] detailed explanation of servlet (use + principle)
大文件如何快速上传?
[stc8g2k64s4] introduction of comparator and sample program of comparator power down detection
LeetCode165-比较版本号-双指针-字符串
Programming philosophy - automatic loading, dependency injection and control inversion
Set up an AI team in the game world and start the super parametric multi-agent "chaos fight"
【NLP】HMM隐马尔可夫+维特比分词
在游戏世界组建一支AI团队,超参数的多智能体「大乱斗」开赛
三、梯度下降求解最小θ
Practice of unified storage technology of oppo data Lake
The difference between having and where in SQL
如何打开Win10启动文件夹?
SQLSERVER事物与锁的问题
Unity_ Code mode add binding button click event
Leetcode167 - sum of two numbers II - double pointer - bisection - array - Search
vscode中文插件不生效问题解决
One of the advanced applications of I / O reuse: non blocking connect -- implemented using select (or poll)
What is the main purpose of PCIe X1 slot?