[英]HTMLCollection [] is undefined
rowGetter = i => {
const row = this.state.estimateItemList[i];
const selectRevison = this.state.selectedEstimate.revision;
const rowLenght = this.state.estimateItemList.length;
const changeColor = document.getElementsByClassName('rd') as
HTMLCollectionOf<HTMLElement>;
if (row.revision > selectRevison) {
for (let x = 0; x < changeColor.length; x++) {
row.changeColor.style.backgroundColor = 'red';
// changeColor.style.backgroundColor = 'red'; //this is get error(Cannot read property 'style' of undefined)
}
return row;
}
}
I want to change the row color when the condition row.revision > this.state.selectedEstimate.revision
. 我想在条件
row.revision > this.state.selectedEstimate.revision
时更改行颜色。 How can I prevent the change of this.color
. 如何防止
this.color
更改。 However im not getting any error but row color is not changing and changeColor : HTMLCollection []
is not get any items. 但是,我没有收到任何错误,但是行颜色没有更改,
changeColor : HTMLCollection []
没有得到任何项目。 it is always undefined
. 它始终是
undefined
。 How can i solve this problem? 我怎么解决这个问题?
Can you please try this : 你能试试这个吗?
const changeColor = document.getElementsByClassName('rd'); const changeColor = document.getElementsByClassName('rd');
instead of : 代替 :
const changeColor = document.getElementsByClassName('rd') as HTMLCollectionOf; const changeColor = document.getElementsByClassName('rd')as HTMLCollectionOf;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.