您当前的位置: 首页 > 

暂无认证

  • 0浏览

    0关注

    92582博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

vue实现跨区域拖放

发布时间:2021-09-06 22:12:26 ,浏览量:0

目录
    • 1、关键代码
    • 2、完整代码
1、关键代码
dragend(item) { console.log(item); if (this.oldItem != this.newItem) { let oldIndex = this.List.indexOf(this.oldItem); let newIndex = this.List.indexOf(this.newItem); let oldflag = false let newflag = false if (oldIndex === -1) { oldflag = true oldIndex = this.list.indexOf(this.oldItem); } if (newIndex === -1) { newflag = true newIndex = this.list.indexOf(this.newItem); } let newList = [...this.List]; // 中间数组,用于交换两个节点 let newlist = [...this.list]; // 中间数组,用于交换两个节点 if (!oldflag) { newList.splice(oldIndex, 1); } else { newlist.splice(oldIndex, 1); } if (!newflag) { newList.splice(newIndex, 0, this.oldItem); } else { newlist.splice(newIndex, 0, this.oldItem); } // 删除老的节点 // newList.splice(oldIndex, 1); // // 在列表目标位置增加新的节点 // newList.splice(newIndex, 0, this.oldItem); // // 更新this.List,触发transition-group的动画效果 this.List = [...newList]; this.list = [...newlist]; } } 
2、完整代码

gitee(码云) - mj01分支 - dragAndDrop 文件

关注
打赏
1653961664
查看更多评论
立即登录/注册

微信扫码登录

0.4346s