简体   繁体   English

Tabulator.js table.getRows() 返回字符串数组而不是 RowComponents

[英]Tabulator.js table.getRows() returning array of strings instead of RowComponents

I'm doing this in my code:我在我的代码中这样做:

let rows = table.getRows(); //as indicated per https://tabulator.info/docs/5.4/update
for (const row in rows) {
  console.log(row);
}

There are three rows in my table and my output is:我的表中有三行,我的 output 是:

0
1
2

Changing console.log(row);更改console.log(row); to console.log(typeof row); console.log(typeof row); I found that getRows() is returning an array of strings instead of RowComponents.我发现getRows()返回的是一个字符串数组,而不是 RowComponents。 Any idea what could be going on?知道会发生什么吗?

You want to use你想用

for (const row of rows) { ...

instead of代替

for (const row in rows) { ...

for in will iterate over the properties of an object whereas for of will iterate the values . for in将迭代 object 的属性,而for of将迭代

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM