VUE項目點擊復制內容(我這里百分之百能用,而且不需要引入插件)
互聯網 2022/1/4 6:07:34
VUE項目,直接上代碼,不需要引入插件!直接復制
上面部分:
<div id="copyVal" class="abc" @click="copywxtap" ref="copytext" > {{weidian}} </div> <div class="recharge_fs"> <div class="tit" > <center @click="copywxtap" > 點擊復制連接 </center> </div> </div>
方法:
methods: { copywxtap() { this.copyContent = this.$refs.copytext.innerText;//也可以直接寫上等于你想要復制的內容 var input = document.createElement("input"); // 直接構建input input.value = this.copyContent; // 設置內容 console.log(input.value); document.body.appendChild(input); // 添加臨時實例 input.select(); // 選擇實例內容 document.execCommand("Copy"); // 執行復制 document.body.removeChild(input); // 刪除臨時實例 alert("復制成功"); }, }

關于找一找教程網
本站文章僅代表作者觀點,不代表本站立場,所有文章非營利性免費分享。
本站提供了軟件編程、網站開發技術、服務器運維、人工智能等等IT技術文章,希望廣大程序員努力學習,讓我們用科技改變世界。
[VUE項目點擊復制內容(我這里百分之百能用,而且不需要引入插件)]http://www.yachtsalesaustralia.com/tech/detail-279746.html
- 2022-05-20單線程的Node.js是如何實現高并發的
- 2022-05-20vue2.x版本中computed和watch的使用入門詳解-watch篇
- 2022-05-20Windows服務器下使用jenkis部署VUE項目
- 2022-05-20Element UI在線運行錯誤, (Uncaught ReferenceError: Vue is not defined)
- 2022-05-20vue 的toast組件
- 2022-05-19Jenkins自動構建部署vue項目到遠程Windows服務器上 騰訊工蜂(git) 一鍵打包+部署+解壓+發布(下)---jenkins的環境配置和使用
- 2022-05-19vue實現lodop打印功能--無感打印
- 2022-05-19面試之JS篇
- 2022-05-18vue axios 賦值后console可以查看到 html調用數據失敗
- 2022-05-18vue安裝