el-carousel更新时,当前页总会跑到最后一页

后端向前端提的bug

  • 当前页保存后,总会跑到最后一页去,
    在这里插入图片描述

获取当前索引

<el-carousel :autoplay='false' indicator-position='outside' trigger="click" arrow="always" @change="updateIndex">
      <el-carousel-item v-for="(form, index) in formList" :key="index">
      </el-carousel-item>
    </el-carousel>
    data(){
    
    
       currentIndex: 0,
    }
     updateIndex(num) {
    
    
      this.currentIndex = num;
      this.init()
    },

将表单索引值==el-carousel当前索引值

  async init() {
    
    
      const {
    
     data } = await GetFormData({
    
     taskId: this.conditions.remark01, formName: this.formTableName })
      // 如果没有数据就清空form,重新加载
      if (data.data.length == 0) {
    
    
        this.getFrom()
        this.formList = []
        this.flag = true
        this.formList.push(this.form)
        return false
      }
      if (data.statusCode == 200) {
    
    
        this.flag = false
        // 获取到当前的表单
        data.data.forEach((el, index) => {
    
    
          if (this.currentIndex == index) {
    
    
            this.form = el.value
            this.form.id = el.id
          }
        })
           // 生成新的列表
          const values = data.data.map(item => item.value)
          this.formList = values
          console.log(  this.form ,"  this.form ");
          console.log("formList",this.formList);
      }

    },

猜你喜欢

转载自blog.csdn.net/Ybittersweet/article/details/129681432