vue3 clipboard3 复制内容
安装
npm install --save vue-clipboard3
使用
<template>
<button @click="copyUrl('123123')"/>
</template>
<script lang="ts" setup>
import useClipboard from 'vue-clipboard3'
const { toClipboard } = useClipboard()
const copyUrl = async (msg:string) => {
try {
//复制
await toClipboard(msg)
console.log(msg)
} catch (e) {
//复制失败
console.error(e)
}
}
</script>