我的index.html文件中有一个表
<table id="userTable">
<tr>
<th>UserId</th>
<th>About you</th>
<th>Age Max</th>
<th>Age Min</th>
<th>City</th>
</tr>
</table>
我正在使用Firebase下拉一些数据以将其显示在表中。
snapshot.forEach(snap => {
console.log(snap.val())
var r = document.getElementById('userTable').insertRow().innerHTML = snap.val().username
var x = r.insertCell(1);
x.innerHTML = snap.val().age
})
firebase逻辑工作正常,我能够获得所需的字段,但似乎无法将数据插入该行的列中。
出现错误:
TypeError: r.insertCell is not a function. (In 'r.insertCell(1)','r.insertCell' is undefined)
计划是创建一行,然后用其余数据填充列。