简体   繁体   中英

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?

i do it and get result:

  a(table: Table) {
    console.log(table)
  }

在此处输入图像描述

But when i try:

a(table: Table) {
  console.log(table.initialized)
}

i get just undefined. if i try:

  a(date: string, table: Table) {
    if (table.initialized) {
      ...
    }
  }

It also treats table.initialized as undefined, meaning it's not in the console bug. Can you explain how it is possible? Func call here:

<p-table #table ... (onLazyLoad)="a(table)" dataKey="id">
try:

 a( table: Table) {
    if (table.initialized) {
      //your code is here....
    }
  }

as your passing table, you one more parameter date, obviously table will empty and you will be getting undefined error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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