由于本人不是專業(yè)前端,只是簡單實(shí)現(xiàn)部分前端功能,在這里簡單記錄自己平時遇到的前端技術(shù)點(diǎn)。
目錄
將數(shù)組直接轉(zhuǎn)成逗號隔開的字符串(20220924)
let arr = [1,2,3]
let arrStr = arr.join(',')
通過js直接實(shí)現(xiàn)復(fù)制方法(20220924)
copyUrl(copyValue){
try {
const input = document.createElement('input');
input.value = copyValue;
document.body.appendChild(input);
input.select()
document.execCommand('copy')
document.body.removeChild(input);
this.$message.success('復(fù)制成功!')
}catch (e){
this.$message.success('復(fù)制失??!')
}
}
實(shí)現(xiàn)復(fù)制功能,在vue的項(xiàng)目中,還可以通過安裝插件vue-clipboard2,但是我在使用的過程中,發(fā)現(xiàn)復(fù)制功能的使用并不是很多,所以直接通過js實(shí)現(xiàn)。