最近使用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"就是獲取數(shù)據(jù)集合的第一個,如果展示全部就不要加此條件
以上這篇vue 循環(huán)加載數(shù)據(jù)并獲取第一條記錄的方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持錯新站長站。
新聞熱點
疑難解答
圖片精選