https://developers.weixin.qq.com/s/6HnNKBmy7FkQ 代码片段
对象型数组添加字段?let arr = [{id:1,name:"张三",num:10},{id:2,name:"李四",num:5},{id:3,name:"王二",num:8},{id:4,name:"麻子",num:6}] arr.map(item=>{ item.price = "" wx.request({ url:"接口", success(res){ item.price = res.data.data.price } }) }) console.log(arr) //[{id:1,name:"张三",num:10,price:5},{id:2,name:"李四",num:5,price:8},{id:3,name:"王二",num:8,price:10},{id:4,name:"麻子",num:6,price:10}] <view wx:for="{{arr}}" wx:key="index"> <view>{{item.num}}</view> <view>{{item.price}}</view> </view> //只显示name,并没有price [图片]
2020-09-24wx.request({ url: '接口', data:{}, methods:"POST", header: { 'Content-Type': 'application/x-www-form-urlencoded', // 默认值 "token":wx.getStorageSync('token') }, success(res){ res.data.content.map(v=>{ console.log(v) v.name = '' http.request('接口',{id:v.id},"GET").then(resp=>{ v.name = 1 //赋值(页面上不显示name字段,但可以显示第一次请求的字段) }) }) that.setData({ list:res.data.content }) console.log(that.data.list) } })
遍历map赋值?遍历一个数组 [{name:"名字1"},{name:"名字2"}].map(v=>{ v.id = 1 }) console.log(数组),值是有的,但是wxml出不来,为什么啊?跪求
2020-09-12我刚才就给接口穿了一个code码,现在报401的错误
登录时的问题?后台给了一个接口,但是需要传code(已经拿到)、微信密码和微信唯一ID,后两个如何获取啊,哪位大神教教我
2020-09-09wx.request({ url: 'http://192.168.1.167:8080/api/member/getDeviceTestName', method:"POST", success:(res)=>{ this.setData({ parameterName:res.data.data }) } })
undefined?wx.request({ url: 'http://192.168.1.167:8080/api/member/getDeviceTestName', method:"POST", success:(res)=>{ this.setData({ parameterName:res.data.data }) } }) 请求完数据并赋值给数组parameterName ,但是在picker的事件parameterName1: function(e) { //检测参数名称 console.log(this.parameterName)}打印却是undefined。为什么啊哪位大神帮帮忙
2020-05-14