在加载数据时,获得的res中有一个值是一个字符串,里面存着诺干个图片的地址,以逗号隔开,
那么,我要怎么分割一下,以方便在wx.for渲染列表的时候,准确的拿到每一个图片地址并渲染出来
data: { showView: false, result: [], imgs:[ ] },
var that = this ; var oData = "" ; wx.request({ url: 'http://t1.easylinking.net:10004/elinkWaiter/order/orderRecommendList.do?userId=134960&timeStamp=0' , //data:{ //userId:'134960', //timeStamp:'0' //}, method: 'POST' , dataType: 'json' , success: function (res) { console.log(res.data) oData = res.data.data.list that.test(oData) that.setData({ result: res.data.data.list }) }, fail: function (res) { console.log( 'submit fail' ); } }) }, test: function (oData){ var that = this ; console.log(oData); for (let i = 0; i < oData.length; i++) { let dataImg = oData[i].imgUrl; console.log(dataImg); that.setData({ imgs:[i] = dataImg.split( "," ) }) }; console.log(that.imgs); } |
我的思路是,另起一个function 单独把存图片的变量 拿出来处理, 大佬们快来骂醒我