vue-elementui使用遇到的问题记录(1)

问题描述:vue 使用elementui的Carousel 走马灯组件,change切换时回调方法的使用?

使用步骤:

代码:

<template>
  <el-carousel indicator-position="outside" @change="handlerChange">
    <el-carousel-item v-for="item in 4" :key="item">
      <h3>{{ item }}</h3>
    </el-carousel-item>
  </el-carousel>
</template>

步骤一:在el-carousel标签上添加 @change="handlerChange“。

代码:

export default { name: 'HelloWorld',
methods: {
  //切换监听方法
handlerChange(index){
  console.log(index);
  }
}
}

步骤二:在方法methods上定义handlerChange,入参为当前切换的对象的索引。

 

如果有错的地方,望指正。


 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章