我要做一个及时渲染的表格,但是使用setData传入数据后发现wx:for没有渲染出表格的数据
//js
onShow(){
this.setData({
content:app.globalData.content,
getweigh:app.globalData.getweigh
})
console.log(this.data.getweigh);
}
//wxml
<view class="tr" wx:for="{{getweigh}}">
<view class="td_1">{{index+1}}</view>
<view class="td">{{getweigh[index].WeighNumber}}</view>
<view class="td">{{getweigh[index].CardNumber}}</view>
<view class="td">{{getweigh[index].Time1+''}}</view>
<view class="td">{{getweigh[index].CarNumber}}</view>
<view class="td">{{getweigh[index].CabientNumber}}</view>
<view class="td">{{getweigh[index].GrossWeight}}</view>
<view class="td">{{getweigh[index].Tare}}</view>
<view class="td">{{getweigh[index].NetWeight}}</view>
<view class="td">{{getweigh[index].Business}}</view>
<view class="td">{{getweigh[index].WeighMethod}}</view>
<view class="td">{{getweigh[index].GoodsName}}</view>
<view class="td">{{getweigh[index].Specifications}}</view>
<view class="td">{{getweigh[index].ForwardUnit}}</view>
<view class="td">{{getweigh[index].Consignee}}</view>
<view class="td">{{getweigh[index].TransportUnit}}</view>
<view class="td">{{getweigh[index].Note}}</view>
<view class="td">{{getweigh[index].WeighMan}}</view>
</view>
刷新一下之后才渲染出来
app.globalData 的值从哪来的?
bindViewTap() {
var that = this;
wx.request({
dataType:JSON,
url: 'http://47.120.36.0:8080/ForRuimA/getweigh',
data:{ //数据
"WeighNumber":"test"
},
method:"POST",//请求方法
header:{ //请求头
"content-type":"application/json"
},
success(res){ //回调
//e为后台返回的值
app.globalData.getweigh = JSON.parse(res.data);
console.log(app.globalData.getweigh)
},
})
wx.switchTab({
url: '../data/data',
success:( function(res) {
// 通过eventChannel向被打开页面传送数据
})
})
},