当前位置:网站首页>js——實現點擊複制功能
js——實現點擊複制功能
2022-04-23 14:55:00 【CaseyWei】
選中複制
<template>
<el-button type="primary" plain @click="onCopy">複制</el-button>
</template>
<script>
export default {
methods:{
onCopy(){
document.execCommand("Copy"); // 執行瀏覽器複制命令
this.$message({
message: '複制成功',
type: 'success'
});
}
}
}
</script>
點擊複制
<template>
<el-button type="primary" plain @click="onCopy">複制</el-button>
</template>
<script>
export default {
methods:{
onCopy(){
const url = '我是要被複制的內容'
let oInput = document.createElement('input')
oInput.value = url
document.body.appendChild(oInput)
oInput.select() // 選擇對象;
document.execCommand('Copy') // 執行瀏覽器複制命令
this.$message({
message: '複制成功',
type: 'success'
})
oInput.remove()
}
}
</script>
版权声明
本文为[CaseyWei]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231454092339.html
边栏推荐
- How does eolink help telecommuting
- 3、 Gradient descent solution θ
- 在游戏世界组建一支AI团队,超参数的多智能体「大乱斗」开赛
- Mds55-16-asemi rectifier module mds55-16
- 1-初识Go语言
- MySQL error packet out of order
- LeetCode149-直线上最多的点数-数学-哈希表
- Frame synchronization implementation
- Epolloneshot event of epoll -- instance program
- Introduction to distributed transaction Seata
猜你喜欢
How does eolink help telecommuting
OC to swift conditional compilation, marking, macro, log, version detection, expiration prompt
三、梯度下降求解最小θ
do(Local scope)、初始化器、内存冲突、Swift指针、inout、unsafepointer、unsafeBitCast、successor、
What is the effect of Zhongfu Jinshi wealth class 29800? Walk with professional investors to make investment easier
Model location setting in GIS data processing -cesium
Redis主从同步
[stc8g2k64s4] introduction of comparator and sample program of comparator power down detection
LeetCode153-寻找旋转排序数组中的最小值-数组-二分查找
【NLP】HMM隐马尔可夫+维特比分词
随机推荐
qt之.pro文件详解
Sword finger offer II 019 Delete at most one character to get palindrome (simple)
填充每个节点的下一个右侧节点指针 II [经典层次遍历 | 视为链表 ]
UML project example -- UML diagram description of tiktok
Programming philosophy - automatic loading, dependency injection and control inversion
每日一题-LeetCode396-旋转函数-递推
What is the main purpose of PCIe X1 slot?
I/O复用的高级应用:同时处理 TCP 和 UDP 服务
剑指 Offer II 019. 最多删除一个字符得到回文(简单)
中富金石财富班29800效果如何?与专业投资者同行让投资更简单
脏读、不可重复读和幻读介绍
【工厂模式详解】工厂方法模式
Borui data and F5 jointly build the full data chain DNA of financial technology from code to user
Contraction mapping theorem
Leetcode162 - find peak - dichotomy - array
3、 Gradient descent solution θ
Want to be an architect? Tamping the foundation is the most important
Flink DataStream 类型系统 TypeInformation
冰冰学习笔记:一步一步带你实现顺序表
【JZ46 把数字翻译成字符串】