问题如题,原来vue1.x可以如下书写:<el-carousel-item v-for="(item, key, index) in picList" :key="index" > <el-button id="carouselBtn" type="text" v-on:click="openDownLoad($index)" > <img :src="item.img" :alt="item.altstring" class="img-responsive"> </el-button> </el-carousel-item>因为在vue2.x中$index被废弃了,那如果使用vue2.x,我该如何获得当时的index?直接写index 点击后 为 undefined求解?
1 回答
繁星淼淼
TA贡献1775条经验 获得超11个赞
<el-carousel-item v-for="(item,index) in picList" >
<el-button id="carouselBtn" type="text" v-on:click="openDownLoad(index)" >
<img :src="item.img" :alt="item.altstring" class="img-responsive">
</el-button>
</el-carousel-item>
methods:{
fun () {
openDownLoad (index) {
console.log(index)
}
}
}
添加回答
举报
0/150
提交
取消