問題是,
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 中的資料。但是,除了手動輸入之外,我不知道該怎么做。有哪些方式?我需要你的幫助。
添加
我想實作無限滾動。額外的加載資料必須再次輸出。就像一個時鐘用戶界面。滾動瀏覽相同的資料時,我想一遍又一遍地顯示它。順便說一句,如果使用了this.if myList.push(this.myList),就不會被處理了…… index 是不是很容易處理呢?我不知道。我能得到幫助嗎?
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 ...
uj5u.com熱心網友回復:
我不知道我是否正確,但你的問題是,這段代碼
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]
將是最簡單和最好的解決方案。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/373202.html
