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"就是獲取數據集合的第一個,如果展示全部就不要加此條件


發佈了32 篇原創文章 · 獲贊 32 · 訪問量 14萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章