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

小程序 文章 2021-02-02 15:01 0 6 全屏看文

如何将回调函数中返回值传给数组中指定行?How to pass the return value in the callback function to the specified row in the array?

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

success: function (res) {

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

    callback()  //回调              

}

success: function (res) { self1.setData({'testquestion[${str}]': res.result.data }); in the callback function, the ${STR} part of this sentence cannot use the passed parameter STR, but it can be replaced by the number 2. How to change it? Thank you! Callback() / / callback}

回答:

Stephen:

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

Damon:

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

Mr.Zhao:

${}别乱用啊,不是用单引号,是反引号

-EOF-