渲染时使用超时功能的缺点是什么?

时间:2020-08-21 14:24:13

标签: javascript angular typescript user-interface

我有大量来自API的数据,需要在UI中显示(特定为网格)。 因为一次显示所有数据(10,000行)真的很慢。

我使用setTimeout加载100行/ 10毫秒

setTimeout(function() { this.delayedLoad(); }.bind(this), 10);

delayedLoad() {
    if(100 < this.data.length) {
      // add next 100 rows to grid, reduce dataSize by 100
      setTimeout(function() { this.delayedLoad(); }.bind(this), 10);
    }    
    else
       // add all rows to grid
  }

但是,在搜索angular中的延迟加载时,我没有找到此解决方案作为答案/推荐,这使我怀疑(作为JS / Typescript新手)这种方法可能存在一些缺点。这种方法有什么缺点吗?

0 个答案:

没有答案
相关问题