当前位置:网站首页>JS - implémenter la fonction de copie par clic
JS - implémenter la fonction de copie par clic
2022-04-23 14:55:00 【Casey Wei】
Sélectionnez copier
<template>
<el-button type="primary" plain @click="onCopy">Copier</el-button>
</template>
<script>
export default {
methods:{
onCopy(){
document.execCommand("Copy"); // Exécuter la commande de copie du navigateur
this.$message({
message: 'Copie réussie',
type: 'success'
});
}
}
}
</script>
Cliquez pour copier
<template>
<el-button type="primary" plain @click="onCopy">Copier</el-button>
</template>
<script>
export default {
methods:{
onCopy(){
const url = 'Je suis le contenu à copier'
let oInput = document.createElement('input')
oInput.value = url
document.body.appendChild(oInput)
oInput.select() // Sélectionner des objets;
document.execCommand('Copy') // Exécuter la commande de copie du navigateur
this.$message({
message: 'Copie réussie',
type: 'success'
})
oInput.remove()
}
}
</script>
版权声明
本文为[Casey Wei]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231454092339.html
边栏推荐
猜你喜欢
利用 MATLAB 编程实现最速下降法求解无约束最优化问题
QT Detailed explanation of pro file
Leetcode167 - sum of two numbers II - double pointer - bisection - array - Search
Thinkphp5 + data large screen display effect
Programming philosophy - automatic loading, dependency injection and control inversion
How to upload large files quickly?
剑指 Offer II 019. 最多删除一个字符得到回文(简单)
成都控制板设计提供_算是详细了_单片机程序头文件的定义、编写及引用介绍
thinkphp5+数据大屏展示效果
qt之.pro文件详解
随机推荐
[NLP] HMM hidden Markov + Viterbi word segmentation
Swift: entry of program, swift calls OC@_ silgen_ Name, OC calls swift, dynamic, string, substring
LeetCode149-直线上最多的点数-数学-哈希表
UML学习_day2
Want to be an architect? Tamping the foundation is the most important
面试官:说一下类加载的过程以及类加载的机制(双亲委派机制)
帧同步 实现
Progress in the treatment of depression
1 - first knowledge of go language
科技的成就(二十一)
epoll 的EPOLLONESHOT 事件———实例程序
Interviewer: let's talk about the process of class loading and the mechanism of class loading (parental delegation mechanism)
OPPO数据湖统一存储技术实践
I/O复用的高级应用之一:非阻塞 connect———使用 select 实现(也可以用 poll 实现)
A good tool: aardio
Role of asemi rectifier module mdq100-16 in intelligent switching power supply
Thinkphp5 + data large screen display effect
select 同时接收普通数据 和 带外数据
Epolloneshot event of epoll -- instance program
vscode中文插件不生效问题解决