vue中v-for渲染,超过两条只显示两条呢?

    <ul class="reply">

        <li class="content" v-for="item in replyList">

          <span class="reply-name">{{item.nickname}}:</span>

          {{item.message}}

        </li>

    </ul>

如何判断数组超过两条,只显示前两条呢?

慕娘9325324
浏览 4057回答 1
1回答

智慧大石

<ul class="reply">&nbsp; &nbsp; &nbsp; &nbsp; <li class="content" v-for="item in replyList.slice(0,2)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="reply-name">{{item.nickname}}:</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {{item.message}}&nbsp; &nbsp; &nbsp; &nbsp; </li>&nbsp; &nbsp; </ul>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript