这篇文章主要讲解了“Vue.Draggable拖拽功能怎么实现”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Vue.Draggable拖拽功能怎么实现”吧!
使用cmd命令在项目根目录下下载安装Vue.Draggable
npm install vuedraggable
在组件中需要使用的引入
import draggable from 'vuedraggable'
注册组件
components:{ draggable }
vue的template代码如
<draggable v-model="itemlis"//开始移动方法 :move="getdata" @update="datadragEnd"//参数配置 :options="{animation: 60,handle:'.drag-icon'}" > <transition-group> <el-row class="album-list-list-item" v-for="(item,index) in itemlis" :key="item.id"> <el-col :span="13"> <div class="grid-content "> <i class="icon drag-icon iconfont icon-Icon-tuozhuai"></i> <el-checkbox v-model="item.checked" :value="item.id"></el-checkbox> <span class="album-info-net">{{item.net}}</span> </div> </el-col> <el-col :span="4"> <div class="grid-content "> <span>{{item.time}}</span> </div> </el-col> <el-col :span="4"> <el-popover placement="left-start" visible-arrow=false width="120" trigger="hover" > <div class="code-img"> <img src="../assets/images/1.png"/> </div> <span slot="reference">{{item.wqcode}}</span> </el-popover> </el-col> <el-col :span="3"> <div class="grid-content album-l-l-tool "> <div class="more-tip-op"> <el-dropdown> <span class="el-dropdown-link"><em class="el-icon-more"></em></span> <el-dropdown-menu slot="dropdown" > <el-dropdown-item :data-url="item.opUrl.removeUrl" @click.native="moveTo(item,$event)">移动</el-dropdown-item> <el-dropdown-item :data-url="item.opUrl.copyUrl" @click.native="copyTo(item,$event)">复制</el-dropdown-item> <el-dropdown-item @click.native="itemDel(index,$event)" :data-url="item.opUrl.delUrl">删除 </el-dropdown-item> <el-dropdown-item :data-url="item.opUrl.exportUrl">导出</el-dropdown-item> <el-dropdown-item :data-url="item.opUrl.editName" @click.native="getEditDialog(item,$event)">编辑</el-dropdown-item> <el-dropdown-item @click.native="getCodeDialog(item,$event)" >查看二维码</el-dropdown-item> </el-dropdown-menu> </el-dropdown> </div> </div> </el-col> </el-row></transition-group></draggable>
Vue的优点
Vue具体轻量级框架、简单易学、双向数据绑定、组件化、数据和结构的分离、虚拟DOM、运行速度快等优势,Vue中页面使用的是局部刷新,不用每次跳转页面都要请求所有数据和dom,可以大大提升访问速度和用户体验。
感谢各位的阅读,以上就是“Vue.Draggable拖拽功能怎么实现”的内容了,经过本文的学习后,相信大家对Vue.Draggable拖拽功能怎么实现这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是编程网,小编将为大家推送更多相关知识点的文章,欢迎关注!