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);
  },
相关推荐
满栀58513 分钟前
vue动态路由效果
前端·javascript·vue.js·前端框架·vue
土豆~23 分钟前
文件名没后缀就打不开:前端文件预览的内容嗅探改造
前端·状态模式
quantdash_cc23 分钟前
告别自建 Requests/BS4 网页爬虫:基于 QuantDash 搭建零维保的高性能量化行情流水线
开发语言·爬虫·python·pandas·量化·quantdash
ydd10010030 分钟前
寻找两个正序数组的中位数 Java 题解,二分分割详解
java·开发语言
半亩码田1 小时前
C#转Python第3.1篇:Python 的 class 没有访问修饰符?面向对象的另一条路
开发语言·python·c#
Euato_Key1 小时前
全栈视野学习Cookie——理解 Cookie 的本质
前端
前端开发呀1 小时前
我的 AI 终端配置清单
前端
敲代码的玉米C1 小时前
测试一直在写你的真实数据根
前端·人工智能·架构
Wzx1980122 小时前
python沙箱和docker沙箱你选对了吗?
开发语言·python·docker
jjw_zyfx2 小时前
css vue vite实现闪烁的呼吸效果
javascript·css·vue.js