当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
Comment eolink facilite le télétravail
One of the advanced applications of I / O reuse: non blocking connect -- implemented using select (or poll)
Swift Protocol 关联对象 资源名称管理 多线程GCD 延迟 once
How does eolink help telecommuting
【Proteus仿真】自动量程(范围<10V)切换数字电压表
Contraction mapping theorem
面试官:说一下类加载的过程以及类加载的机制(双亲委派机制)
博睿数据携手F5共同构建金融科技从代码到用户的全数据链DNA
中富金石财富班29800效果如何?与专业投资者同行让投资更简单
I/O复用的高级应用之一:非阻塞 connect———使用 select 实现(也可以用 poll 实现)
Raised exception class eaccexviolation with 'access violation at address 45efd5 in module error
OC 转 Swift 条件编译、标记、宏、 Log、 版本检测、过期提示
Leetcode exercise - 396 Rotation function
The art of automation
脏读、不可重复读和幻读介绍
GIS数据处理-cesium中模型位置设置
[proteus simulation] automatic range (range < 10V) switching digital voltmeter
Explain TCP's three handshakes in detail
Flink datastream type system typeinformation
[jz46 translate numbers into strings]