html52.com
我爱小程序-开发者交流社区

在WXML添加真实数据出问题?

在WXML文件里添加真实数据以后,模拟器显示不出来。打印了数据,数据是存在的但是无法调用。

调试器内打印出来的数据(数据是从云数据库获取的)如下:

调试器内打印出来的数据(数据是从云数据库获取的)如下:代码如下:

代码如下:

<wxs src="../../utils/util.wxs" module="util" />


<view class="container">
  <view class="weibo-group" wx:for="{{weibos}}" wx:for-item="weibo">
    <view class="user-group">
      <image class="avatar" src="{{weibo.author.avatarUrl}}"> </image>
      <view class="right-info">
        <view class="username">{{weibo.author.nickName}}</view>
        <view class="detail-info">
          <view class="time">{{util.timeFormat(weibo.create_time)}}</view>
          <view class="from">来自{{weibo.device}}</view>
        </view>
      </view>
    </view>
    <view class="weibo-content-group">
      <view class="content">{{weibo.content}}</view>
      <bolock wx:if="{{weibo.images.length > 0}}">
        <!-- 一张图片的情况 -->
        <view wx:if="{{weibo.images.length===1}}" class="image-list-group">
          <image src="{{weibo.images}}" mode="aspectFill" style="width:100%; max-height:400rpx;"> </image>
        </view>
        <!-- 两张或四张图片情况 -->
        <view wx:elif="{{weibo.images.length===2||weibo.images.length===4}}" class="image-list-group">
          <image wx:for="{{weibo.images}}" wx:for-item="image" src="{{image}}" mode="aspectFill"
            style="width:{{twoImageSize}}px;height:{{twoImageSize}}px">
          </image>
        </view>
        <!-- 3、5、6、7、8、9张图片的情况 -->
        <view wx:else class="image-list-group">
          <image wx:for="{{weibo.images}}" wx:for-item="image" src="{{image}}" mode="aspectFill"
            style="width:{{threeImageSize}}px;height:{{threeImageSize}}px">
          </image>
        </view>
      </bolock>
      <!-- 上传视频的情况 -->
      <block wx:if="{{weibo.video}}">
        <view class="image-list-group">
          <video src="{{weibo.video}}"></video>
        </view>
      </block>
    </view>

模拟器显示:

模拟器显示:

网友回复

微盟:
weibo.weibo.author.avatarUrl

楼上正解 
沃德天·维森陌·拉莫帅🌝:
看你的数据结构,应该要写成weibo.weibo.author.avatarUrl

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付