下面的代码只是我整个代码的一个片段,我遇到的问题是第一个 while 循环返回所有实例,但第二个 while 循环只返回一个实例。我试过把它们放在不同的功能中,但这没有帮助,有人可以帮忙吗?
function refreshCurveData() {
selectedDate = document.querySelectorAll(".buyclass .column-date.sorting_1")[1].textContent;
buyPriceTable = document.querySelectorAll(".buyclass td.column-price");
buyVolTable = document.querySelectorAll(".buyclass td.column-volume");
sellPriceTable = document.querySelectorAll(".sellclass td.column-price");
sellVolTable = document.querySelectorAll(".sellclass td.column-volume");
let i = 0;
do {
var buyPriceData1 = buyPriceTable[i].textContent;
var buyVolData1 = buyVolTable[i].textContent;
buyPriceData[i] = {
x: parseFloat(buyPriceData1.replace(/\,/g, '')),
y: parseFloat(buyVolData1.replace(/\,/g, ''))
};
i++;
}
while (document.querySelectorAll(".buyclass .column-date.sorting_1")[i].textContent === selectedDate);
let j = 0;
do {
var sellPriceData1 = sellPriceTable[j].textContent;
var sellVolData1 = sellVolTable[j].textContent;
sellPriceData[j] = {
x: parseFloat(sellPriceData1.replace(/\,/g, '')),
y: parseFloat(sellVolData1.replace(/\,/g, ''))
};
j++;
}
while (document.querySelectorAll(".sellclass .column-date.sorting_1")[j].textContent === selectedDate);
}
setInterval(() => {
refreshCurveData();
scatterChart.update();
}, 2500);