大家好,这里是我的问题的简化
我使用 *ngfor 在模板中创建了元素
<table >
<thead>
<tr>
<th *ngFor="let item of array" > {{item}}</th>
</tr>
</thead>
</table>
Run Code Online (Sandbox Code Playgroud)
在 .ts 文件中我有表格
array = [1,2,3,4];
Run Code Online (Sandbox Code Playgroud)
然后当我尝试在控制台中显示元素时
var cells = document.getElementsByTagName('th'); //or getElementById or anything..
console.log(cells[1]);
Run Code Online (Sandbox Code Playgroud)
它显示 未定义