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);
  },
相关推荐
用户27050777252430 分钟前
MCP 最小 Server 实测:3 个 JSON-RPC 报错与修法
前端
用户4993350250732 分钟前
一人VIP账号多人共用:Web 代理里的会话共享怎么实现
前端
用户老李33 分钟前
无线电自学教程 05:第一台收音机——从矿石机到 SDR
前端
IPIPD41 分钟前
Node.js请求遇到503怎么重试?先解析Retry-After,再做有上限退避
前端
葡萄城技术团队1 小时前
dsh-spreadjs-editor 的集成链路:把 SpreadJS Designer 嵌进 Agent 工作台
前端
FlyWIHTSKY2 小时前
vue2和vue3有什么区别,用法上有哪些区别
前端·javascript·vue.js
码云之上2 小时前
10 颗一模一样的「Edit」:中后台 Web Agent 怎么找到对的那一行
前端·人工智能·浏览器
量化分析码农2 小时前
【Python量化多因子实战 04】因子暴露不是 alpha:市值与行业中性化实战
前端·后端
不可能片场3 小时前
Electron 发布 正文写入的三条通道与读回口径
前端·electron
程序员大阳3 小时前
副队长JavaScript教程(66)-本地存储实战:待办事项网页的开发
javascript·json·实战·待办事项·本地存储·案例