当前位置:网站首页>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
边栏推荐
猜你喜欢
Comment eolink facilite le télétravail
中富金石财富班29800效果如何?与专业投资者同行让投资更简单
Swift: entry of program, swift calls OC@_ silgen_ Name, OC calls swift, dynamic, string, substring
三、梯度下降求解最小θ
22年了你还不知道文件包含漏洞?
Leetcode149 - maximum number of points on a line - Math - hash table
A good tool: aardio
Leetcode151 - invert words in string - String - simulation
Leetcode153 - find the minimum value in the rotation sort array - array - binary search
Is asemi ultrafast recovery diode interchangeable with Schottky diode
随机推荐
Swift: entry of program, swift calls OC@_ silgen_ Name, OC calls swift, dynamic, string, substring
多语言通信基础 06 go实现grpc的四种数据流模式实现
Detailed comparison between asemi three-phase rectifier bridge and single-phase rectifier bridge
《JVM系列》 第七章 -- 字节码执行引擎
SVN详细使用教程
Share 20 tips for ES6 that should not be missed
Arduino for esp8266串口功能简介
帧同步 实现
如何打开Win10启动文件夹?
每日一题-LeetCode396-旋转函数-递推
Interviewer: let's talk about the process of class loading and the mechanism of class loading (parental delegation mechanism)
LeetCode 练习——396. 旋转函数
Swift:Entry of program、Swift调用OC、@_silgen_name 、 OC 调用Swift、dynamic、String、Substring
pnpm安装使用
Want to be an architect? Tamping the foundation is the most important
22年了你还不知道文件包含漏洞?
Async void caused the program to crash
拼接hql时,新增字段没有出现在构造方法中
LeetCode151-颠倒字符串中的单词-字符串-模拟
Provided by Chengdu control panel design_ It's detailed_ Introduction to the definition, compilation and quotation of single chip microcomputer program header file