当前位置:网站首页>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
边栏推荐
- Role of asemi rectifier module mdq100-16 in intelligent switching power supply
- MySQL error packet out of order
- 大文件如何快速上传?
- Programming philosophy - automatic loading, dependency injection and control inversion
- 线程同步、生命周期
- Is asemi ultrafast recovery diode interchangeable with Schottky diode
- Epoll's et, lt working mode -- example program
- 【工厂模式详解】工厂方法模式
- 多语言通信基础 06 go实现grpc的四种数据流模式实现
- Detailed comparison between asemi three-phase rectifier bridge and single-phase rectifier bridge
猜你喜欢
Swift protocol Association object resource name management multithreading GCD delay once
机器学习之逻辑回归(Logistic Regression)原理讲解和实例应用,果断收藏
Swift: entry of program, swift calls OC@_ silgen_ Name, OC calls swift, dynamic, string, substring
LeetCode 练习——396. 旋转函数
SVN详细使用教程
LeetCode167-两数之和II-双指针-二分-数组-查找
Leetcode165 compare version number double pointer string
Introduction to Arduino for esp8266 serial port function
Share 20 tips for ES6 that should not be missed
成都控制板设计提供_算是详细了_单片机程序头文件的定义、编写及引用介绍
随机推荐
Flink datastream type system typeinformation
填充每个节点的下一个右侧节点指针 II [经典层次遍历 | 视为链表 ]
Mds55-16-asemi rectifier module mds55-16
Advanced application of I / O multiplexing: Processing TCP and UDP services at the same time
Is asemi ultrafast recovery diode interchangeable with Schottky diode
Go basic reflection
Difference between like and regexp
Swift protocol Association object resource name management multithreading GCD delay once
How does eolink help telecommuting
SQL中HAVING和WHERE的区别
qt之.pro文件详解
博睿数据携手F5共同构建金融科技从代码到用户的全数据链DNA
Unity_ Code mode add binding button click event
go基础 反射
Interviewer: let's talk about the process of class loading and the mechanism of class loading (parental delegation mechanism)
Vscode Chinese plug-in doesn't work. Problem solving
Realization of four data flow modes of grpc based on Multilingual Communication
Arduino for esp8266串口功能简介
Detailed comparison between asemi three-phase rectifier bridge and single-phase rectifier bridge
Alexnet model