首页 > 语言 > JavaScript > 正文

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

2024-05-06 15:29:28
字体:
来源:转载
供稿:网友

最近使用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"就是获取数据集合的第一个,如果展示全部就不要加此条件

以上这篇vue 循环加载数据并获取第一条记录的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持错新站长站。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选