zoukankan      html  css  js  c++  java
  • VUE:v-for获取列表前n个数据、中间范围数据、末尾n条数据的方法

    说明:

      1.开发使用的UI是mintUI,

    要求:

    1.获取6到13之间的数据:items.slice(6,13)

    <mt-cell v-for="(item,index) in items.slice(6,13)" :title="item.title" :key='index'>
        <a :href="item.url" :title="item.title" class="list-url">
             <img :src="item.src" :alt="item.title" class="list-img"/>
        </a>
    </mt-cell>

    2.获取小于0到6之间的数据:(两种)

      a:items.slice(0,6)

    <mt-cell v-for="(item,index) in items.slice(0,6)" :title="item.title" :key='index'>
           <a :href="item.url" :title="item.title" class="list-url">
               <img :src="item.src" :alt="item.title" class="list-img"/>
           </a>
    </mt-cell>

      b:v-if="index < 6"

    <mt-cell v-for="(item,index) in items" v-if="index < 6" :title="item.title" :key='index'>
           <a :href="item.url" :title="item.title" class="list-url">
               <img :src="item.src" :alt="item.title" class="list-img"/>
           </a>
    </mt-cell>

    3.获取最后6条数据:items.slice(items.length-6,items.length)

    <mt-cell v-for="(item,index) in items.slice(items.length-6,items.length)" :title="item.title" :key='index'>
           <a :href="item.url" :title="item.title" class="list-url">
               <img :src="item.src" :alt="item.title" class="list-img"/>
           </a>
    </mt-cell>
  • 相关阅读:
    【每天一道PAT】1001 A+B Format
    C++ STL总结
    开篇
    happen-before原则
    java多线程的状态转换以及基本操作
    集合初始容量
    fail-fast机制
    Stack
    Iterator
    Vector
  • 原文地址:https://www.cnblogs.com/chig/p/11988378.html
Copyright © 2011-2022 走看看