收藏
回答

问题:电脑上显示正常,手机上不显示图片?

.js文件

Page({

  data: {

    imgUrls: [],

  },


 onLoad: function (options) {

    var that = this;

    wx.request({

      url: 'https://62222.qicp.vip/index.php/Api/Index/index',

      method:'post',

      data: {},

      header: {

        'Content-Type':  'application/x-www-form-urlencoded'

      },

      success: res => { 

        console.log(res.data,'控制台输出');

        let ggtop = res.data.ggtop;

        that.setData({

          imgUrls:ggtop,

        });

      },


.wxml文件

<view>

<swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" circular="true">

<block wx:for="{{imgUrls}}"  wx:for-item="course" wx:key="imgUrls">

<swiper-item>

<image src="{{course.photo}}" class="slide-image" width="100%" height="200" />

</swiper-item>

</block>

</swiper>

</view>


执行结果

电脑console:

{ggtop: Array(4), procat: Array(4), prolist: Array(4), brand: Array(8), course: Array(6)}

brand: Array(8)

0: {id: "1", name: "小米手环", photo: "https://62222.qicp.vip/Data/UploadFiles/brand/20170630/1498818446765084.jpg"}

1: {id: "2", name: "小米电源", photo: "https://62222.qicp.vip/Data/UploadFiles/brand/20170630/1498818537250741.jpg"}

2: {id: "3", name: "小米路由", photo: "https://62222.qicp.vip/Data/UploadFiles/brand/20170630/1498818583379669.jpg"}

3: {id: "4", name: "小米笔记本", photo: "https://62222.qicp.vip/Data/UploadFiles/brand/20170630/1498818644256526.jpg"


手机console:

{"ggtop":[{"id":"10","name":"%E9%A6%96%E9%A1%B5%E8%BD%AE%E6%92%AD","photo":"https:\/\/62222.qicp.vip\/Data\/UploadFiles\/adv\/20170524\/1495588800716222.jpg"},{"id":"5","name":"%E9%A6%96%E9%A1%B5%E8%BD%AE%E6%92%AD","photo":"https:\/\/62222.qicp.vip\/Data\/UploadFiles\/adv\/20170525\/1495684434521009.jpg"},{"id":"2","name":"%E6%BB%9A%E5%8A%A8%E5%B9%BF%E5%91%8A%E5%9B%BE2","photo":"https:\/\/62222.qicp.vip\/Data\/UploadFiles\/adv\/20170524\/1495589027693993.jpg"},


问题:电脑上显示正常,手机上不显示图片,<view>"{{imgUrls}}"</view>,显示发现imgUrls变成了一个整字符串,里面竟然不是对象。

<view>"{{imgUrls[3]}}"</view>,显示字符"t"



哪位大佬,帮我看看,哪里出了问题,谢谢

最后一次编辑于  2020-07-06
回答关注问题邀请回答
收藏
登录 后发表内容
问题标签