Mini Program reported an error in setData.

Page({
  data: {
    articles: [{type:"news",list:[]},{type:"zixun",list:[]}],
    navbar: [{name:"",type:"news"},{name:"",type:"zixun"}],
    currentNavbar: 0
  }),

made a tab tab toggle drop-down function to load more data

this.setData({
    "articles[0].list": initdata.concat(res.data.data)
})

articles [0] .list this allows you to get data normally
articles [this.data.currentNavbar] .list cannot be set to dynamic
report an error as follows: Only number 0-9 could inside []: articles [that.data.currentNavbar] .list

Mar.09,2021

method 1: use es6 syntax

this.setData({
  [`articles[${this.data.currentNavbar}].list`]: initdata.concat(res.data.data)
})

method 2: overall assignment

articles[this.data.currentNavbar].list = initdata.concat(res.data.data)
this.setData({
  articles: articles
})

reference link

  1. Link 1
  2. Link 2
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-1b35a31-2bfb8.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-1b35a31-2bfb8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?