小程序指定更改数组/对象的某一个值,优化上拉加载

/*
    改变数组/对象里的某一个值
*/
data:{
    questionList: [{
            id: 1,
            questionName: '1、课程内容丰富、详实',
            questionValue: 0
        }
    ],
    obj: {
        text: 123
    }
},
qValueEvt(e){
    //修改对象中的属性值
    this.setData({
      ['obj.text']: 3
    })

    let qVal = `questionList[${e.currentTarget.dataset.rateindex}].questionValue`
    this.setData({
        [qVal]: e.detail
    })
}


/*
    优化上拉加载
*/
const oldList = this.data.list
const newGoodsList = res.returnData.data
const nList = [...oldList, ...newGoodsList]
let newData = {}; //新变更数据
for(let i in nList){
    newData['list['+i+']'] = nList[i]
}
this.setData(newData);//赋值列表数据

 

posted @ 2020-05-19 14:22  日升月恒  阅读(296)  评论(0)    收藏  举报