Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript React ANTD DatePicker HTMLCollection在提取元素/值时不显示活动值_Javascript_Reactjs_Antd_Nodelist_Htmlcollection - Fatal编程技术网

Javascript React ANTD DatePicker HTMLCollection在提取元素/值时不显示活动值

Javascript React ANTD DatePicker HTMLCollection在提取元素/值时不显示活动值,javascript,reactjs,antd,nodelist,htmlcollection,Javascript,Reactjs,Antd,Nodelist,Htmlcollection,当我使用ANTD DatePicker并使用箭头转到下一个面板时。UI会更新,但我无法从HTMLCollection或节点列表中提取活动值 第一次打开面板时: var yrCell = document.getElementsByClassName("ant-calendar-year-panel-year"); console.log(yrCell) // logs 2019-2030 in a HTMLCollection for (let item of yrC

当我使用ANTD DatePicker并使用箭头转到下一个面板时。UI会更新,但我无法从HTMLCollection或节点列表中提取活动值

第一次打开面板时:

    var yrCell = document.getElementsByClassName("ant-calendar-year-panel-year");

    console.log(yrCell) // logs 2019-2030 in a HTMLCollection

    for (let item of yrCell) {
        console.log(item.innerText); // logs 2019-2030
    }

    for (let i = 0; i < yrCell.length; i++) {
        console.log(yrCell[i]); // logs 2019-2030
    }

    console.log(yrCell) // logs 2019-2030 in a HTMLCollection
var yrCell=document.getElementsByClassName(“ant日历年面板年”);
console.log(yrCell)//在HTMLCollection中记录2019-2030
用于(yrCell的let项目){
console.log(item.innerText);//日志2019-2030
}
for(设i=0;i
现在的问题是当我单击面板上的“下一步”箭头时

var yrCell=document.getElementsByClassName(“ant日历年面板年”);
console.log(yrCell)//在HTMLCollection中记录2029-2040
用于(yrCell的let项目){
console.log(item.innerText);//仍然记录2019-2030
}
for(设i=0;i
如果HTMLCollection已更新,UI已更新并播放“更晚”的值,并且在我的代码中,我在尝试从中提取特定值之前和之后读取更新的值,那么这些值如何不存在


非常感谢您的帮助

因此,可能是真实DOM与虚拟DOM之间存在一些问题,我发现结果是有人使用超时来修复不同的问题。但我在我的代码中尝试了这一点,它解决了这个问题,所以我将我的逻辑包装到了这个代码中

setTimeout(() => {
    [...yearCells].forEach(yearCell => {
        for (var count = 0; count < this.state.yearsThatCoveragesWereChanged.length; count++) {
            if (this.state.yearsThatCoveragesWereChanged[count].effectiveFrom === yearCell.innerText) {
                 //logic
            }
        }
    });
}, 0);
setTimeout(()=>{
[…yearCells].forEach(yearCell=>{
对于(var count=0;count
setTimeout(() => {
    [...yearCells].forEach(yearCell => {
        for (var count = 0; count < this.state.yearsThatCoveragesWereChanged.length; count++) {
            if (this.state.yearsThatCoveragesWereChanged[count].effectiveFrom === yearCell.innerText) {
                 //logic
            }
        }
    });
}, 0);