当前位置:网站首页>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
边栏推荐
- 线程同步、生命周期
- The difference between having and where in SQL
- [jz46 translate numbers into strings]
- raised exception class EAccexxViolation with ‘Access violation at address 45EFD5 in module 出错
- Resolve the conflict between computed attribute and input blur event
- LeetCode 练习——396. 旋转函数
- Chapter 7 of JVM series -- bytecode execution engine
- 在游戏世界组建一支AI团队,超参数的多智能体「大乱斗」开赛
- Alexnet model
- 面试官:说一下类加载的过程以及类加载的机制(双亲委派机制)
猜你喜欢

面试官:说一下类加载的过程以及类加载的机制(双亲委派机制)

UML学习_day2

Provided by Chengdu control panel design_ It's detailed_ Introduction to the definition, compilation and quotation of single chip microcomputer program header file

你还不知道责任链模式的使用场景吗?
![[NLP] HMM hidden Markov + Viterbi word segmentation](/img/9a/b39a166320c2f2001f10913f789c90.png)
[NLP] HMM hidden Markov + Viterbi word segmentation

Leetcode151 - invert words in string - String - simulation

Model location setting in GIS data processing -cesium

Swift protocol Association object resource name management multithreading GCD delay once

1 - first knowledge of go language

Programming philosophy - automatic loading, dependency injection and control inversion
随机推荐
剑指 Offer II 019. 最多删除一个字符得到回文(简单)
MDS55-16-ASEMI整流模块MDS55-16
Swift Protocol 关联对象 资源名称管理 多线程GCD 延迟 once
2-GO variable operation
拼接hql时,新增字段没有出现在构造方法中
如何打开Win10启动文件夹?
中富金石财富班29800效果如何?与专业投资者同行让投资更简单
Svn detailed use tutorial
多语言通信基础 06 go实现grpc的四种数据流模式实现
Comment eolink facilite le télétravail
SQLSERVER事物与锁的问题
Model location setting in GIS data processing -cesium
博睿数据携手F5共同构建金融科技从代码到用户的全数据链DNA
冰冰学习笔记:一步一步带你实现顺序表
SVN详细使用教程
Sword finger offer II 019 Delete at most one character to get palindrome (simple)
Leetcode162 - find peak - dichotomy - array
22年了你还不知道文件包含漏洞?
牛客网数据库SQL实战详细剖析(26-30)
Explanation and example application of the principle of logistic regression in machine learning