小程序中条件渲染用法

有时完善内容显示需要不同条件显示不同内容

用到了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>

地址:

有时完善内容显示需要不同条件显示不同内容 用到了WX:if 最新评论 { {item.likes}} { {item.author}} { {item.content}} { {item.times}} 暂时还没有评论喔! 地址:
经验分享 程序员 微信小程序 职场和发展