How does js merge arrays

data() {
    return {
        listData: [],
        listTotal: []
      }
},
methods: {
   loadData: function(index, size) {
       var _this = this;
       this.$get("article/list", {
            p: index, //
            size: size //
        }).then(function(res) {
            _this.listData = res.list;
            if (index == 1) { //
                uni.setStorage({
                    key: "storage_list",
                    data: _this.listData
                });
            }
       });
   }
}
onReachBottom() { //
   _this.pageIndexPP;
   _this.loadData(_this.pageIndex, _this.pageSize); //
   uni.getStorage({
            key: "storage_list",
            success: function(res) {
               _this.listTotal = res.data.concat(_this.listData);
            }
        });
   
}

-sharp-sharp
this _ this.listData is a different 10-item array. How to put the _ this.listData in a _ this.listTotal? but when I write this, I can only merge the previous one, not overlay and merge each time. The value of _ this.listData will change every time I cycle. How to merge it?

Nov.09,2021

 success: function(res) {
    _this.listTotal = [..._this.listTotal, ...res.data.concat(_this.listData)];
 }

merging arrays can be done with es6. Array flattening method


Why not merge it directly on listTotal?

data() {
  return {
    listData: [],
    listTotal: []
  }
},
/*  */
methods: {
  loadData: function(index, size) {
    let _this = this;
    this.$get('article/list', {
      p: index, //
      size: size //
    }).then(function(res) {
      _this.listTotal = _this.listTotal.concat(res.listData);
    });
  }
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3aba8-2af7d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3aba8-2af7d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?