From edef6ae8f59823258ce610c9074d32e698958b51 Mon Sep 17 00:00:00 2001 From: ZZJ <10913410+zzj2100@user.noreply.gitee.com> Date: 星期四, 28 七月 2022 15:30:44 +0800 Subject: [PATCH] 本地图片适配 --- src/components/Price.vue | 31 +++++++++++++++++++++++++++---- 1 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/components/Price.vue b/src/components/Price.vue index 9d641b5..1a03a7e 100644 --- a/src/components/Price.vue +++ b/src/components/Price.vue @@ -1,17 +1,19 @@ <template> - <div class="Price" v-if="priceNew"> - 锟�<span class="newPrice">{{ priceN1 }}</span + <div class="Price" style="height: 30px"> + <!-- 锟�<span class="newPrice">{{ priceN1 }}</span >{{ priceN2 }}/骞� <span class="iconSave" v-if="showIcon">鐪�</span> - <span class="oldPrice">锟{ priceO1 }}{{ priceO2 }}/骞�</span> + <span class="oldPrice">锟{ priceO1 }}{{ priceO2 }}/骞�</span> --> </div> </template> <script> export default { props: { - priceNew: {}, + priceNew: { + default: 0, + }, showIcon: { default: false, }, @@ -42,6 +44,27 @@ this.priceO2 = ".00"; } }, + + watch: { + priceNew() { + const priceO = (this.priceNew * 1.2 + "").split("."); + const priceN = (this.priceNew + "").split("."); + if (priceN.length > 1) { + this.priceN1 = priceN[0]; + this.priceN2 = "." + priceN[1]; + } else { + this.priceN1 = priceN[0]; + this.priceN2 = ".00"; + } + if (priceO.length > 1) { + this.priceO1 = priceO[0]; + this.priceO2 = "." + priceO[1]; + } else { + this.priceO1 = priceO[0]; + this.priceO2 = ".00"; + } + }, + }, }; </script> -- Gitblit v1.8.0