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);
  },
相关推荐
前端小L6 分钟前
双指针专题(三):去重的艺术——「三数之和」
javascript·算法·双指针与滑动窗口
0和1的舞者6 分钟前
Spring AOP详解(一)
java·开发语言·前端·spring·aop·面向切面
web小白成长日记10 分钟前
在Vue样式中使用JavaScript 变量(CSS 变量注入)
前端·javascript·css·vue.js
MoonBit月兔15 分钟前
年终 Meetup:走进腾讯|AI 原生编程与 Code Agent 实战交流会
大数据·开发语言·人工智能·腾讯云·moonbit
QT 小鲜肉16 分钟前
【Linux命令大全】001.文件管理之which命令(实操篇)
linux·运维·服务器·前端·chrome·笔记
智航GIS21 分钟前
8.2 面向对象
开发语言·python
C_心欲无痕21 分钟前
react - useImperativeHandle让子组件“暴露方法”给父组件调用
前端·javascript·react.js
小小星球之旅29 分钟前
CompletableFuture学习
java·开发语言·学习
kylezhao20191 小时前
C# 语言基础(变量、数据类型、流程控制、面向对象编程)
开发语言·计算机视觉·c#·visionpro
霖鸣1 小时前
Minecraft通过kubejs进行简单魔改
javascript