How to click the @ click event in vue to copy some data from data to the clipboard

as the title, @ click event, to get some data data, you need to put this content in the clipboard.

Feb.28,2021

you can put your data into a hidden input element, select it and copy it.

<input id="copyme" value="your data">
$('-sharpcopyme').select();
document.execCommand('copy');

I wrote an article: Vue with clipboard.js to click the button to copy the content to the clipboard

< hr >

I hope it will be helpful to you!


give you a copy method written by myself, just pass in what you want to copy and determine whether it is on the clipboard by returning the result.

function copyText (text) {
  let copyInput = document.createElement('INPUT')
  copyInput.type = 'text'
  copyInput.style.width = '1px'
  copyInput.style.height = '1px'
  copyInput.style.border = 0
  copyInput.style.outline = 0
  document.body.appendChild(copyInput)
  copyInput.value = text
  copyInput.select()
  const result = document.execCommand('Copy')
  document.body.removeChild(copyInput)
  return result
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bdec86-31421.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bdec86-31421.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?