我是歌謠 放棄很容易 但是堅持一定很酷
最近需要做一個一鍵復制的一個功能
大概需求是
一個element的table里面有個多行資料

看到眼前這個需求一開始那真的是一頭霧水
是要復制一行嗎
后來慢慢研究 不是這樣的理解
前言
需求設計前的思考
最后確定了需求
代碼實作
第一步
js里面定義一個復制函式
/*復制操作 第一步定義copy的方法*/
function copy(msg){
let input = document.createElement('input')
input.value = https://blog.csdn.net/weixin_43392489/article/details/msg
document.body.appendChild(input)
input.select()
document.execCommand('copy')
document.body.removeChild(input)
Vue.prototype.$message.success('復制成功!')
return msg
}
第二步直接export default匯出
export default {
/*匯入方法 變數 資料*/
isEmpty,
jsonToString,
/*匯出復制任務的方法*/
copy,
API_PATH,
/*
第三步 引入
import Util from '@/assets/js/util'
第四步 方法呼叫
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/280229.html
標籤:其他
上一篇:BUAA_OO_2021_ 第二單元 - 難度巔峰之多執行緒電梯
下一篇:Web安全:跨站點攻擊csrf
