当前位置:网站首页>js——实现点击复制功能
js——实现点击复制功能
2022-04-23 14:54: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://blog.csdn.net/caseywei/article/details/124331763
边栏推荐
猜你喜欢
Using MATLAB programming to realize the steepest descent method to solve unconstrained optimization problems
Set up an AI team in the game world and start the super parametric multi-agent "chaos fight"
Model location setting in GIS data processing -cesium
Vous ne connaissez pas encore les scénarios d'utilisation du modèle de chaîne de responsabilité?
Swift:Entry of program、Swift调用OC、@_silgen_name 、 OC 调用Swift、dynamic、String、Substring
do(Local scope)、初始化器、内存冲突、Swift指针、inout、unsafepointer、unsafeBitCast、successor、
Swift: entry of program, swift calls OC@_ silgen_ Name, OC calls swift, dynamic, string, substring
Mds55-16-asemi rectifier module mds55-16
What is the effect of Zhongfu Jinshi wealth class 29800? Walk with professional investors to make investment easier
We reference My97DatePicker to realize the use of time plug-in
随机推荐
LeetCode153-寻找旋转排序数组中的最小值-数组-二分查找
PCIe X1 插槽的主要用途是什么?
利用 MATLAB 编程实现最速下降法求解无约束最优化问题
自动化的艺术
3、 Gradient descent solution θ
1N5408-ASEMI整流二极管1N5408
Async keyword
Vscode Chinese plug-in doesn't work. Problem solving
Introduction to dirty reading, unrepeatable reading and phantom reading
Epoll's et, lt working mode -- example program
eolink 如何助力遠程辦公
LeetCode167-两数之和II-双指针-二分-数组-查找
Svn detailed use tutorial
pnpm安装使用
填充每个节点的下一个右侧节点指针 II [经典层次遍历 | 视为链表 ]
Alexnet model
I/O复用的高级应用之一:非阻塞 connect———使用 select 实现(也可以用 poll 实现)
What is the main purpose of PCIe X1 slot?
What is the effect of Zhongfu Jinshi wealth class 29800? Walk with professional investors to make investment easier
Swift protocol Association object resource name management multithreading GCD delay once