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);
  },
相关推荐
小伟童鞋5 分钟前
c++中导出函数调用约定为__stdcall类型函数并指定导出函数名称
开发语言·c++
百思可瑞教育5 分钟前
Vue中使用keep-alive实现页面前进刷新、后退缓存的完整方案
前端·javascript·vue.js·缓存·uni-app·北京百思可瑞教育
维C泡泡5 分钟前
C++初认、命名规则、输入输出、函数重载、引用+coust引用
开发语言·c++
yinuo10 分钟前
Uni-App跨端实战:APP的WebView与H5通信全流程解析(03)
前端
a73601511 分钟前
二十二、包管理与发布 (Cargo 进阶)
开发语言·rust
yinuo13 分钟前
Uni-App跨端实战:支付宝小程序WebView与H5通信全流程解析(02)
前端
郝学胜-神的一滴1 小时前
深入探索 C++ 元组:从基础到高级应用
开发语言·c++·stl·软件工程
I'm a winner1 小时前
第七章:AI进阶之------输入与输出函数(一)
开发语言·人工智能·python·深度学习·神经网络·microsoft·机器学习
木心操作1 小时前
js生成excel表格进阶版
开发语言·javascript·ecmascript
GISer_Jing1 小时前
sqb&ks二面(准备)
前端·javascript·面试