vue 循环加载数据并获取第一条记录

 最近使用elment ui和vue.js,遇到需要像c:foreach类似的效果,就找了

      vue的API:https://cn.vuejs.org/v2/guide/list.html#v-for-with-v-if

      element ui:http://element.eleme.io/#/zh-CN/component/input

用法:

<el-card class="box-card"  v-for="(month,index)  in monthdata"  
   v-if="index==0"  v-bind:month="month" v-bind:index="index">
   <div slot="header" class="clearfix">
	<span style="line-height: 36px;font-size:17px ;color:#666 ;">
           <i style="color:#20a0ff ;font-style: normal;"> {{ index }} - {{ month.C_YEAR_MONTH }}</i> 月度目标
       </span>
       <i style="float: right;color:#20a0ff;line-height: 36px;cursor: pointer;" 
          class="el-icon-caret-bottom" v-on:click="change()"></i>
  </div>
</el-card>
index就是索引,从0开始,v-if="index==0"就是获取数据集合的第一个,如果展示全部就不要加此条件


猜你喜欢

转载自blog.csdn.net/linadadan/article/details/73250931