当前位置: 代码迷 >> 综合 >> vue拖拽之 draggable
  详细解决方案

vue拖拽之 draggable

热度:101   发布时间:2023-11-26 03:36:42.0

移入模块

package.json中引入
"vuedraggable": "^2.20.0",

import draggable from 'vuedraggable'

<draggable v-model="myapply"  @update="datadragEnd"><transition-group class="group clearfix navul"><div v-for="(nav,i) in myapply" :key="nav.id"  class="dragli">{
   {nav.menuAlias}}<i @click="removeApply(nav,i)" v-if='defaultapply.indexOf(nav.menuName)==-1'>-</i></div></transition-group>
</draggable>
//更新组件
datadragEnd (evt) {console.log('拖动前的索引 :' + evt.oldIndex)console.log('拖动后的索引 :' + evt.newIndex)
},