只需修改 "this.array[0]..." 打字稿代码

Simply modify "this.array[0]..." the typescript code

问题是,

  this.myList[0],
  this.myList[1],
  this.myList[2],
  this.myList[3], // mylist data is 0 ~ 18...
  this.myList[18]

我试了一下,

for (let i = 0; i < this.myList.length; i++) {
  this.myList.push(this.myList[i]);
}

但是不起作用。我是这样写的,

this.myList.push(
  this.myList
);

打印如下。

 ...
   17: {name: undefined, value: Array(1), deptId: '100', deptName: 'asd', isChecked: false}
   18: {name: undefined, value: Array(1), deptId: '101', deptName: 'test', isChecked: false}
// I saved it repeatedly, but it was wrong.
   19: (20) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, Array(20)]
// I saved it repeatedly, but it was wrong.

当活动开始时,我想再次加载存储在myList 中的数据。 但是,除了手动输入,我不知道该怎么做。 有哪些方法?我需要你的帮助。

添加+

我想实现无限滚动。 必须再次输出额外的加载数据。 像一个时钟 ui。 当滚动浏览相同的数据时,我想一遍又一遍地显示它。 对了,用了this.IfmyList.push(this.myList),就不处理了。。。 索引是处理它的简单方法吗?我不知道。我能得到帮助吗?

for ex) 
[ 1, 2, 3, ...1000 ] : myList 1st loading, 
[ 1000, 1, 2, 3, ...1000 ] : event > myList 1st + 2nd loading 
[ 1000, 1, 2, 3, ...1000 ] : event > myList 2nd + 3rd loading ...

我不知道我是否理解正确,但你的问题是,这段代码

for (let i = 0; i < this.myList.length; i++) {
  this.myList.push(this.myList[i]);
}

修改数组及其长度,

因此,每次添加一项时,数组都会变长,依此类推。 这最终会杀死你的堆,因为数组不断扩展到无穷大。

也许您想循环直到达到初始数组的长度?如果是这样你应该循环直到

i<myList.length 

但是

的简单连接
this.myList.concat(this.myList)

this.myList = [...this.myList, ...this.myList]

将是最简单和最好的解决方案。