如何将回调函数中返回值传给数组中指定行?

发布于 8 年前作者 yshen3095 次浏览最后编辑 8 年前来自 ask

success: function (res) {

self1.setData({‘testquestion[${str}]’: res.result.data }); 在回调函数中此句的${str}部分无法用传递的参数str,但换成数字2就可以,如何改?谢谢啦!

    callback()  //回调              

}

2 回复
pingcai
pingcai1 楼5 年前

self1.setData({testquestion[str]: res.result.data }); 

xiaomin
xiaomin2 楼5 年前

{`testquestion[${str}]`: res.result.data }