收藏
回答

setData在安卓中可以,在ios中部分不生效?

  data: {
    goods_detail:{},
    cart:[],
    collect:{},
    isCollect:false,
  },
  onLoadfunction (options{
    const phoneCheck = wx.getStorageSync('phone')
    if(!phoneCheck){
      wx.switchTab({
        url'../index/index',
      })
    }
    wx.showLoading();
    var that = this;
    let app = getApp();
    let setUrl = app.globalData.ip+"/goods/detail?gid="+options["gid"];
    async function getDetail(){
      try{
        const res = await request({url:setUrl});
        await wx.hideLoading();
        that.setData({
          goods_detail:res.data,
        })
      }catch(err){
        console.log(err);
      }
    };
    getDetail()
  },

别的都可以setData,只有这个goods_detail不可以,在真机调试里面只有这个是empty的,偶尔可以加载出来。安卓是可以的,换成ios就不行了,有大哥知道是为啥吗。


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

1 个回答

  • 武曲心
    武曲心
    2022-04-07

    你得先说说请求回来有没有数据

    2022-04-07
    有用
    回复 3
    • bluefire
      bluefire
      2022-04-07
      network那里的response数据都是正常的
      2022-04-07
      回复
    • 武曲心
      武曲心
      2022-04-07回复bluefire
      把await wx.hideLoading();拿到try的后面或者getDetail()后面,去掉await,排除是不是try里面是不是被wx.hideLoading()断掉了
      2022-04-07
      1
      回复
    • bluefire
      bluefire
      2022-04-07回复武曲心
      把hideLoading拿到后面就可以了,谢谢!!
      2022-04-07
      回复
登录 后发表内容