适合需要复制地址到第三方打单软件,比如拼多多、淘宝、抖店等等第三方打单软件打印快递单发货的。
效果如下
//复制地址
copy: function() {
let that = this;
let copyText = this.orderDatalist.orderInfo.real_name + ',' + this.orderDatalist.orderInfo.user_phone + ',' + this.orderDatalist.orderInfo.user_address
console.log('复制成功',copyText)
const input = document.createElement('input');
document.body.appendChild(input);
input.setAttribute('value',copyText);//这里是数据
input.setAttribute('create',1);
input.select();
document.execCommand("Copy");
var list=document.getElementsByTagName('input')
var inputList = Array.prototype.slice.call(list)
inputList.forEach((item)=>{
if(item.getAttribute('create'))document.body.removeChild(item);
});
this.$Message.info('复制成功→' + copyText); //弹窗提醒复制成功,不需要可注释
},