小程序中条件渲染用法


 

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

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

欢迎关注,有问题一起学习欢迎留言、评论。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM