Cuando se actualiza el-carrusel, la página actual siempre se ejecutará hasta la última página

Error planteado desde el backend hasta el frontend

  • Después de guardar la página actual, siempre irá a la última página.
    inserte la descripción de la imagen aquí

obtener el índice actual

<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()
    },

Valor de índice de formulario == valor de índice actual del carrusel

  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);
      }

    },

Supongo que te gusta

Origin blog.csdn.net/Ybittersweet/article/details/129681432
Recomendado
Clasificación