当前位置:网站首页>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
边栏推荐
- 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
- Frame synchronization implementation
- Share 3 tools, edit 5 works at home and earn more than 400
- 抑郁症治疗的进展
- UML项目实例——抖音的UML图描述
- Introduction to dirty reading, unrepeatable reading and phantom reading
- raised exception class EAccexxViolation with ‘Access violation at address 45EFD5 in module 出错
- qt之.pro文件详解
- How do I open the win10 startup folder?
猜你喜欢
成都控制板设计提供_算是详细了_单片机程序头文件的定义、编写及引用介绍
Leetcode exercise - 396 Rotation function
Redis master-slave synchronization
[stc8g2k64s4] introduction of comparator and sample program of comparator power down detection
Sword finger offer II 019 Delete at most one character to get palindrome (simple)
Interviewer: let's talk about the process of class loading and the mechanism of class loading (parental delegation mechanism)
Model location setting in GIS data processing -cesium
Detailed comparison between asemi three-phase rectifier bridge and single-phase rectifier bridge
Brute force of DVWA low -- > High
Daily question - leetcode396 - rotation function - recursion
随机推荐
Redis master-slave synchronization
冰冰学习笔记:一步一步带你实现顺序表
Async keyword
PCIe X1 插槽的主要用途是什么?
OPPO数据湖统一存储技术实践
QT Detailed explanation of pro file
Unity_ Code mode add binding button click event
pnpm安装使用
LeetCode 练习——396. 旋转函数
Bingbing learning notes: take you step by step to realize the sequence table
Thread synchronization, life cycle
qt之.pro文件详解
剑指 Offer II 019. 最多删除一个字符得到回文(简单)
Leetcode165 compare version number double pointer string
分享3个使用工具,在家剪辑5个作品挣了400多
在游戏世界组建一支AI团队,超参数的多智能体「大乱斗」开赛
OC 转 Swift 条件编译、标记、宏、 Log、 版本检测、过期提示
UML project example -- UML diagram description of tiktok
Borui data and F5 jointly build the full data chain DNA of financial technology from code to user
async关键字