打印squareLists是空
getSquareList是个异步操作哦。你把 that.setData写到 squareItem[item.square_id] = res 的后面一排
你需要这样写
async
function
yourHandleDataFunction() {
if
(res.statusCode == 200) {
const squareItems = {}
await Promise.all(res.data.map((item, index) => async () {
const data = await that.getSquareList(item.square_id)
squareItems[item.square_id] = data
})
that.setData(...)
}