vue點擊復制
<script>
// 創建Vue實例
Vue.createApp({
methods: {
// 定義handleClick方法
handleClick() {
alert('按鈕被點擊了!');
},
copyOrderId2(orderId) {
var input = document.createElement("input"); // 創建input對象
input.value = orderId; // 設置復制內容
document.body.appendChild(input); // 添加臨時實例
input.select(); // 選擇實例內容
document.execCommand("Copy"); // 執行復制
document.body.removeChild(input); // 刪除臨時實例
alert('復制成功!');
},
},
}).mount('#app'); // 將Vue實例掛載到#app元素上
</script>
<span @click="copyOrderId2('12121221212')"> 點擊復制 </span>

浙公網安備 33010602011771號