this.$options.watch.watchOrdersFormPrice.apply(this);//主动触发watchOrdersFormPrice
watch:{
watchOrdersFormPrice: function(){
if( !this.ordersForm.alone_sold_price && this.ordersForm.ginfo.goods_id ){
var price_info = this.ordersForm.ginfo.price_info;
if( this.ordersForm.ginfo.open_flags & (1<<3) ){//规格
var sku_txt_list = this.ordersForm.spec_radios.map(v=>`${v.name}||${v.val}`).join(',');
price_info = this.ordersForm.ginfo.spec_sku_list.find(v=>v.sku_txt_list===sku_txt_list) || price_info;
}
this.ordersForm.price = (price_info.price / 1000).toFixed(2);
this.ordersForm.sold_price = (price_info.suggest_price / 1000).toFixed(2);
}
},
copy1(value) {//不可复制换行符
const input = document.createElement('input');
input.setAttribute('readonly', 'readonly');
input.value = value;
document.body.appendChild(input);
input.setSelectionRange(0, 9999);
input.select();
document.execCommand('copy');
document.body.removeChild(input);
this.$message.success({message:'复制成功!'});
},
copy2(value) {
// 可复制换行符
window.navigator.clipboard
.writeText(value)
.then(() => {
this.$message.success({message:'复制成功!'});
})
.catch(() => {
this.$message.error({message:'复制失败,请手动复制!'});
});
}
this.$options.data().form
第一步:引入qrcode.min.js
第二步:
this.qrcode_div = this.qrcode_div || document.createElement('div');
var qr = new QRCode( this.qrcode_div, {
text: res.data.data.back_url,
width: 300,
height: 300,
correctLevel: QRCode.CorrectLevel.H//容错率,L/M/H
});
this.previewImageUrl = qr._oDrawing._elCanvas.toDataURL();
this.qrcode_div.innerHTML = '';//清除信息
'爱'.charCodeAt(0).toString(16)
结果:'7231'
charCodeAt返回码点
转16进制
\u 转义字符用来表示 Unicode 编码
于是
'\u7231'代表的就是爱(把16进制转成字符)
String.fromCharCode(parseInt(7231, 16));
?