element拖拽表单拖拽排序

bash 复制代码
    <el-button @click="addfirst()" type="text" class='el-icon-circle-plus-outline' ></el-button>

    <draggable
      v-model="myArray"
      group="people"
      @change="change"
      @start="start"
      @end="end"
    >
      <div class="item" v-for="(first, index) in myArray" :key="index">
        <!-- {{ index }} -->
        <el-input  style='width:20%'  clearable v-model.trim="first.name" placeholder="请输入"></el-input>
        <el-button type="text" class="el-icon-delete" style='width:4%'  @click.prevent="removefirst(first)"></el-button>

      </div>
    </draggable>

    <el-button class="searchBtn" @click="tijiao()" type="primary">提交</el-button>
bash 复制代码
   data() {
          return {
              myArray: [
	                {
	                  name:''
	                },
              ],
          }
    }
bash 复制代码
 // 删除1
  removefirst(item) {
        var index = this.myArray.indexOf(item)
        this.myArray.splice(index, 1)
    },
    addfirst(){
        this.myArray.push({
            name:'',
        });
    },
    tijiao(){
      console.log(this.myArray)
    },
   // 监听拖拽
  change(event) {
    // console.log("change");
    // console.log(event);
    // console.log(this.myArray);
  },
  // 开始拖拽
  start(event) {
    // console.log("start");
    // console.log(event);
    // console.log(this.myArray);
  },
  // 结束拖拽
  end(event) {
    // console.log("end");
    // // event.item  拖拽的本身
    // // event.to      拖拽的目标列表
    // // event.from    拖拽之前的列表
    // // event.oldIndex    拖拽前的位置
    // // event.newIndex    拖拽后的位置
    // console.log(event);
    // console.log(this.myArray);
  },
相关推荐
IT_陈寒36 分钟前
Vue的watch把我坑惨了,原来要这样用才靠谱
前端·人工智能·后端
1-1=039 分钟前
Vue 3 模板语
前端·javascript·vue.js
用户7610304473711 小时前
【转战智能眼镜开发】ROKID AIUI 小游戏 亚马逊标枪项目实战讲解
前端
风卿1 小时前
看着AI写代码太孤独了,来欣赏星云吧:一个DSH 装饰插件
前端·javascript
牧艺1 小时前
弹层不用再手算坐标了:CSS Anchor Positioning 从原理到可上线
前端·javascript·css
用户老李1 小时前
YOLO 目标检测自学教程 07:YOLOv3——多尺度预测
前端
moshuying2 小时前
ESP32 墨水屏金价牌(上):从点亮到把图片推过去
前端
李剑一2 小时前
别再抬杠,前端岗已经没了!无论前后端,我们最终都要成“全干”工程师
前端·面试
Highcharts.js2 小时前
Highcharts 仪表盘与速度仪图表库介绍
前端·信息可视化·仪表板·highcharts·图表开发·图表库·仪表可视化
愚坤2 小时前
前端真有意思,JS还能独立做项目?
前端·javascript·github