data: {
checkboxList: [
{name: ‘综合部’, value:‘0’},
{name: ‘总经办’, value:‘1’}
],
},
现在需要渲染一个checkbox列表,数据格式如上:
var that = this;
wx.request({
url: ‘https://XXXXXXXXXXX/GetDepartment’,
data: {
departmentid: depID,
},
success: function(res){
for (var i = 0; i < res.data.datalist.length; i++){
console.log(res.data.datalist[i].F_DepartmentName);
console.log(res.data.datalist[i].F_DepartmentID);
that.setData({
checkboxList: [
{name: res.data.datalist[i].F_DepartmentName, value: i}
]
})
}
},
有没有办法将请求回来的数据push进checkboxList而不是像setData每次都重新设置数据????