![](/img/trans.png)
[英]I can print a state object array, but when I try to access a value from an object in the array, the whole object is undefined
[英]Why in ts, if I print the whole object, I see the value of the field, but if I try to access exactly this field, is it undefined?
我这样做并得到结果:
a(table: Table) {
console.log(table)
}
但是当我尝试时:
a(table: Table) {
console.log(table.initialized)
}
我只是不确定。 如果我尝试:
a(date: string, table: Table) {
if (table.initialized) {
...
}
}
它还将 table.initialized 视为未定义,这意味着它不在控制台错误中。 你能解释一下这是怎么可能的吗? 函数在这里调用:
<p-table #table ... (onLazyLoad)="a(table)" dataKey="id">
try:
a( table: Table) {
if (table.initialized) {
//your code is here....
}
}
作为您的传递表,您还有一个参数日期,显然表将为空并且您将收到未定义的错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.