收藏
回答

使用setData后传输数组后wx:for无法及时渲染?

我要做一个及时渲染的表格,但是使用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>

刷新一下之后才渲染出来

回答关注问题邀请回答
收藏

1 个回答

  • Mr.Zhao
    Mr.Zhao
    2023-07-27

    app.globalData 的值从哪来的?

    2023-07-27
    有用 1
    回复 20
    • ClassNotFound
      ClassNotFound
      2023-07-27
      在另一个页面通过request请求获取的
      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向被打开页面传送数据
            })
          })
        },
      2023-07-27
      回复
    • Mr.Zhao
      Mr.Zhao
      2023-07-27回复ClassNotFound
      代码不是按顺序执行的  这个清楚吗
      2023-07-27
      回复
    • ClassNotFound
      ClassNotFound
      2023-07-27回复Mr.Zhao
      我知道,data数据的改变和渲染是两个线程的,文档里有说
      2023-07-27
      回复
    • Mr.Zhao
      Mr.Zhao
      2023-07-27回复ClassNotFound
      说的不是一码事
      2023-07-27
      回复
    • ClassNotFound
      ClassNotFound
      2023-07-27回复Mr.Zhao
      那您教教我吧
      2023-07-27
      回复
    查看更多(15)
登录 后发表内容