From 8d422a336c2fe22526e6169ff087dd3809175115 Mon Sep 17 00:00:00 2001
From: lxf <1371462558@qq.com>
Date: Mon, 19 May 2025 17:46:25 +0800
Subject: [PATCH] 首页k线修复
---
src/components/list-quotation/index.vue | 34 ++++++++++++++++++++++------------
1 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/src/components/list-quotation/index.vue b/src/components/list-quotation/index.vue
index 81156d0..6a47449 100644
--- a/src/components/list-quotation/index.vue
+++ b/src/components/list-quotation/index.vue
@@ -219,6 +219,7 @@
type: "left", //left 从左往右 right 从有王座
sortVal: 0,
kLineData: this.generateKLineData(),
+ klineDataList: [],
};
},
props: {
@@ -247,7 +248,10 @@
},
mounted() {
this.listData.forEach((item) => {
- item.kLineData = this.generateKLineData();
+ if (!item.kLineData) {
+ item.kLineData = this.generateKLineData();
+ this.klineDataList.push(item.kLineData);
+ }
});
this.$nextTick(() => {
this.drawKLine();
@@ -281,8 +285,16 @@
canvasList.forEach((canvas, index) => {
if (!canvas) return;
- // if (this.listData[index].kLineData) return;
-
+ if (!this.listData[index].kLineData) {
+ this.listData[index].kLineData =
+ this.klineDataList[index] || this.generateKLineData();
+ this.klineDataList.push(this.listData[index].kLineData);
+ }
+ // console.log(
+ // "kLineData",
+ // this.listData[index].kLineData,
+ // this.klineDataList
+ // );
const ctx = canvas.getContext("2d");
const width = canvas.width;
const height = canvas.height;
@@ -314,7 +326,7 @@
ctx.stroke();
});
- console.log("listData: ", this.listData);
+ // console.log("listData: ", this.listData);
},
//排序
listSort(val) {
@@ -385,6 +397,12 @@
},
watch: {
listData() {
+ this.drawKLine();
+ // this.listData.forEach((item) => {
+ // if (!item.kLineData) {
+ // item.kLineData = this.generateKLineData();
+ // }
+ // });
if (this.active == 0) {
this.showList = [...this.listData];
} else if (this.active == 1) {
@@ -399,14 +417,6 @@
this.showList = [...this.listData].sort(this.compare("volume", "up"));
}
this.$forceUpdate();
- this.$nextTick(() => {
- // 为每一项补充 kLineData
- this.listData.forEach((item) => {
- if (!item.kLineData) {
- item.kLineData = this.generateKLineData();
- }
- });
- });
},
},
};
--
Gitblit v1.9.3