小程序解决移动端不显示方案

解决手机端无法输出的问题

wx.request({
      url: 'https://www.baiyigroup.com/Api/slideshow',
      header: {
        'Content-Type': 'json',
      },
      method: 'GET',
      success: function (res) {
        //去除BOM
        const rawData = res.data;
        let parsedData = rawData;
        if (typeof rawData === 'string') { //假设解析错误回到json字符串那么就去掉bom解析
          try {
            parsedData = JSON.parse(rawData.trim()) //删除字符串开头空格
          } catch (e) {
            console.error(e);
          }
        } 
        console.log(parsedData);
        // 调用函数赋值
        that.slideshow(parsedData);
      }
    })
posted @ 2022-12-06 22:21  轻风细雨_林木木  阅读(36)  评论(0编辑  收藏  举报