From 734f88378528ccfa6683ad1e9cd706a7b293fb3c Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@iotlink.com>
Date: 星期四, 13 八月 2020 16:15:53 +0800
Subject: [PATCH] fix: rounding the compare sorce to keep only two decimals
---
src/components/subComponents/CardItem.vue | 45 ++++++++++++++++++---------------------------
1 files changed, 18 insertions(+), 27 deletions(-)
diff --git a/src/components/subComponents/CardItem.vue b/src/components/subComponents/CardItem.vue
index 3c9791c..e549a88 100644
--- a/src/components/subComponents/CardItem.vue
+++ b/src/components/subComponents/CardItem.vue
@@ -37,7 +37,7 @@
background: getUrl(data.baseInfo[initialIndex].bwType)
}"
>
- <b>{{ `${data.baseInfo[initialIndex].compareScore}%` }}</b>
+ <b>{{ data.baseInfo[initialIndex].compareScore | percentage }}</b>
</div>
</div>
</div>
@@ -87,10 +87,6 @@
@mouseenter="cardMouseenter($event)"
@mouseleave="cardMouseleave($event)"
>
- <!-- <p :title="data.baseInfo[0].compareScore" class="score">
- <span v-if="data.id">{{ data.compareScore }}%</span>
- <span v-else>{{ data.baseInfo[0].compareScore }}%</span>
- </p>-->
<p>
<span class="fontStyle color222">{{ data.picDate }}</span>
</p>
@@ -200,7 +196,7 @@
class="score"
style="font-family: PingFangSC-Medium;font-size: 20px;color: #3D68E1;letter-spacing: 0.4px;"
>
- <span>{{ data.baseInfo[0].compareScore }}%</span>
+ <span>{{ data.baseInfo[0].compareScore | percentage}}</span>
</p>
<p
:style="data.baseInfo[0].bwType == '0' ? 'font-size:12px;line-height:20px' : 'color:red;font-size:12px;line-height:20px'"
@@ -316,8 +312,8 @@
v-if="VideoPhotoData.uploadType"
style="font-family: PingFangSC-Medium;font-size: 20px;color: #3D68E1;letter-spacing: 0.4px;"
>
- <span v-if="data.id">{{ data.compareScore }}%</span>
- <span v-else>{{ data.baseInfo[0].compareScore }}%</span>
+ <span v-if="data.id">{{ data.compareScore | percentage}}</span>
+ <span v-else>{{ data.baseInfo[0].compareScore | percentage}}</span>
</p>
<p :title="data.picDate">
<span class="fontStyle color222">{{ data.picDate }}</span>
@@ -502,18 +498,14 @@
default: "search"
}
},
- watch: {
- data: {
- handler(val, oldVal) {
- console.log('鏁版嵁鍙戠敓鍙樺寲')
- this.$forceUpdate()
- },
- deep: true
- }
- },
computed: {
isId() {
return this.data.id
+ }
+ },
+ filters: {
+ percentage(score) {
+ return score.toFixed(2) + "%"
}
},
data() {
@@ -525,17 +517,16 @@
overflowState: true
};
},
+ watch: {
+ data: {
+ handler(val, oldVal) {
+ console.log('鏁版嵁鍙戠敓鍙樺寲')
+ this.$forceUpdate()
+ },
+ deep: true
+ }
+ },
methods: {
- watchWindow() {
- // console.log('height')
- // this.$nextTick(() => {
- // document.querySelectorAll('.compareScore111').forEach(ele => {
- // ele.style.bottom = this.getBottom()
- // console.log("鍏冪礌鐨勬牱寮忓�硷細",ele.style.bottom)
- // });
- // this.$forceUpdate()
- // })
- },
getBottom() {
// let imgDom = document.getElementById(str)
let imgDom = this.$refs.firstImg
--
Gitblit v1.8.0