vue中使用vuedraggable 实现拖拽

1.yarn add vuedraggable  或者  npm i -S vuedraggable  先引入 vuedraggable  

 

 

2.在需要拖拽的页面引入注册

 

 

3.在页面中使用

1
2
3
4
5
6
<!-- 绑定循环出来的数组  chosen-class是拖拽时自定义的样式  force-fallback为开启自定义样式   animation是拖拽速度  update是拖拽完成后的事件-->
<draggable v-model="myArray" chosen-class="chosen" force-fallback="true" group="people" animation="1000" @update="ondate">
                <transition-group style="display:flex;width:30vw;flex-wrap:wrap;">
                    <div class="item" v-for="(element,index) in myArray" :key="index">{{element.name}}</div>
                </transition-group>
</draggable>

  

4.效果

 

 

 

 


  

posted @   热爱前端的5号机器  阅读(2655)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示