在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML  Office/ vue中怎么實(shí)現(xiàn)點(diǎn)擊@click事件,將data中的某個(gè)數(shù)據(jù)復(fù)制到剪切板

vue中怎么實(shí)現(xiàn)點(diǎn)擊@click事件,將data中的某個(gè)數(shù)據(jù)復(fù)制到剪切板

如題,@click事件,獲取某個(gè)data數(shù)據(jù),需要將這個(gè)內(nèi)容放到剪切板中.....

回答
編輯回答
離人歸

可以將你的數(shù)據(jù)放入一個(gè)隱藏的input元素中,選中后復(fù)制。

<input id="copyme" value="your data">
$('#copyme').select();
document.execCommand('copy');
2018年5月16日 14:58
編輯回答
大濕胸
2017年6月25日 02:23
編輯回答
話寡

給你一個(gè)我自己寫的復(fù)制方法 只需執(zhí)行 傳入你想復(fù)制的內(nèi)容 通過返回結(jié)果來(lái)判斷是否到剪貼板

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
}
2018年1月3日 15:58