有時完善內容顯示需要不同條件顯示不同內容
用到了WX:if
<text class="comments-title">最新評論</text>
<view class="comments-box" wx:if="{{comments.length > 0}}">
<view class="comments-list" wx:for="{{comments}}" wx:for-item="item" wx:for-index="i">
<view class="comments-avatar"><image class="comments-avatar-img" src="{{item.avatar}}"/></view>
<view class="comments-main">
<view class="comments-author">
<view class="comments-zan">{{item.likes}}</view>
<text>{{item.author}}</text>
</view>
<view class="comments-content">{{item.content}}</view>
<view class="comments-data">{{item.times}}</view>
</view>
</view>
</view>
<!-- 沒有評論 -->
<view class="not-comments" wx:else> 暫時還沒有評論喔! </view>
文章來源:劉俊濤的博客
地址:http://www.cnblogs.com/lovebing
歡迎關注,有問題一起學習歡迎留言、評論。