当前位置:网站首页>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
边栏推荐
- How does eolink help telecommuting
- UML项目实例——抖音的UML图描述
- Raised exception class eaccexviolation with 'access violation at address 45efd5 in module error
- 2-GO variable operation
- January 1, 1990 is Monday. Define the function date_ to_ Week (year, month, day), which realizes the function of returning the day of the week after inputting the year, month and day, such as date_ to
- capacitance
- Do (local scope), initializer, memory conflict, swift pointer, inout, unsafepointer, unsafebitcast, success
- 【NLP】HMM隐马尔可夫+维特比分词
- Progress in the treatment of depression
- Swift: entry of program, swift calls OC@_ silgen_ Name, OC calls swift, dynamic, string, substring
猜你喜欢
Swift: entry of program, swift calls OC@_ silgen_ Name, OC calls swift, dynamic, string, substring
LeetCode153-寻找旋转排序数组中的最小值-数组-二分查找
LeetCode162-寻找峰值-二分-数组
Comment eolink facilite le télétravail
Introduction to distributed transaction Seata
UML project example -- UML diagram description of tiktok
1-初识Go语言
UML项目实例——抖音的UML图描述
Daily question - leetcode396 - rotation function - recursion
Leetcode149 - maximum number of points on a line - Math - hash table
随机推荐
How do I open the win10 startup folder?
Achievements in science and Technology (21)
Is asemi ultrafast recovery diode interchangeable with Schottky diode
LeetCode167-两数之和II-双指针-二分-数组-查找
科技的成就(二十一)
如何打开Win10启动文件夹?
MySQL报错packet out of order
Svn detailed use tutorial
Using MATLAB programming to realize the steepest descent method to solve unconstrained optimization problems
Daily question - leetcode396 - rotation function - recursion
Async void caused the program to crash
Swift protocol Association object resource name management multithreading GCD delay once
Swift - literal, literal protocol, conversion between basic data types and dictionary / array
大文件如何快速上传?
Arduino for esp8266串口功能简介
Swift:Entry of program、Swift调用OC、@_silgen_name 、 OC 调用Swift、dynamic、String、Substring
三、梯度下降求解最小θ
Epoll's et, lt working mode -- example program
Progress in the treatment of depression
Want to be an architect? Tamping the foundation is the most important