1、主动触发函数
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);}},
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:'复制失败,请手动复制!'});});
}
3、vue获取原始data
this.$options.data().form
4、后台生成二维码
第一步:引入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 = '';//清除信息
5、字符转Unicode(16进制)
'爱'.charCodeAt(0).toString(16)
结果:'7231'
charCodeAt返回码点
转16进制
\u 转义字符用来表示 Unicode 编码
于是
'\u7231'代表的就是爱(把16进制转成字符)
6、Unicode 转字符
String.fromCharCode(parseInt(7231, 16));