search

Home  >  Q&A  >  body text

javascript - Limit the number of items in vue list rendering

How to limit rendering to only 2 pieces of data?

<ul>
    <li v-for="i in data" v-text="i"></li>
</ul>

data: ['a','b','c','d']
仅有的幸福仅有的幸福2780 days ago1072

reply all(2)I'll reply

  • 女神的闺蜜爱上我

    女神的闺蜜爱上我2017-07-05 10:51:19

    <ul>
        <li v-for="(i, index) in data" v-if="index < 2" v-text="i"></li>
    </ul>

    reply
    0
  • 漂亮男人

    漂亮男人2017-07-05 10:51:19

    <ul>

    <li v-for="i in data.slice(0, 2)" v-text="i"></li>

    </ul>

    reply
    0
  • Cancelreply