yarn add vue-clipboard3

or

npm install --save vue-clipboard3

 

 




<template lang="html"> <div> <input type="text" v-model="text"> <button @click="copy">Copy!</button> </div> </template> <script lang="ts"> import { defineComponent, ref } from '@vue/composition-api' import useClipboard from 'vue-clipboard3' export default defineComponent({ setup() { const { toClipboard } = useClipboard() const text = ref('') const copy = async () => { try { await toClipboard(text.value) console.log('Copied to clipboard') } catch (e) { console.error(e) } } return { copy, text } } }) </script>

相关文章:

  • 2021-06-12
  • 2021-06-05
  • 2022-01-31
  • 2022-12-23
  • 2021-08-19
  • 2022-12-23
  • 2022-12-23
  • 2022-02-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-30
  • 2021-06-19
  • 2022-12-23
  • 2021-12-10
相关资源
相似解决方案