首页 > 其他分享 >draggable 组件使用(拖拽排序及拖拽交换功能 swap)

draggable 组件使用(拖拽排序及拖拽交换功能 swap)

时间:2023-05-08 10:34:21浏览次数:26  
标签:name items age 拖拽 draggable swap futureIndex id log

一、template 里 <draggable   v-model="myArray"   group="people"   @start="drag = true"   @end="drag = false" >   <div v-for="element in myArray" :key="element.id">{{ element.name }}</div> </draggable>
<table>   <draggable     v-model="items"     tag="tbody"     :move="handleMove"     @end="handleDragEnd"     :options="{ animation: 500 }"   >     <tr class="movable" v-for="item in items" :key="item.id">       <td>{{ item.id }}</td>       <td>{{ item.name }}</td>       <td>{{ item.age }}</td>     </tr>   </draggable> </table>   二、data 里 myArray: [   { id: 1, name: "name1" },   { id: 2, name: "name2" },   { id: 3, name: "name3" } ], items: [   { id: 1, name: "Bianka Effertz", age: 37 },   { id: 2, name: "Mckayla Bogan", age: 20 },   { id: 3, name: "Estevan Mann", age: 17 },   { id: 4, name: "Cloyd Ziemann", age: 55 } ]   三、methods 里 handleDragEnd(e) {   console.log(e);   console.log(e.newIndex);   console.log(e.oldIndex);   console.log("dragEnd");
  this.futureItem = this.items[this.futureIndex];   this.movingItem = this.items[this.movingIndex];   const _items = Object.assign([], this.items);   _items[this.futureIndex] = this.movingItem;   _items[this.movingIndex] = this.futureItem;
  this.items = _items; }, handleMove(e) {   const { index, futureIndex } = e.draggedContext;   this.movingIndex = index;   this.futureIndex = futureIndex;   return false; // disable sort },  

标签:name,items,age,拖拽,draggable,swap,futureIndex,id,log
From: https://www.cnblogs.com/heroljy/p/17380969.html

相关文章

  • scandir,major和minor,state,无锁机制----比较交换CAS Compare And Swap,dirent,sprintf,fop
    文章目录1.Linuxc目录操作函数scandir2.Linux系统设备(device)的major和minornumber3.state4.无锁机制----比较交换CASCompareAndSwap5.dirent6.sprintf7.fopen8.atoi函数9.strtok10.strtol1.Linuxc目录操作函数scandir(1)头文件:#include<dirent.h>定义函数:intscandir(......
  • vue 拖拽相关
    dragable学习参考:https://blog.csdn.net/qq_41619796/article/details/116027212参考:https://blog.csdn.net/lhz_333/article/details/123403911......
  • 【Vue】vue3 vue-pdf-embed 实现pdf预览、缩放、拖拽、旋转和左侧菜单选择
    实际效果安装插件pnpminstallvue-pdf-embedpnpminstallvue3-pdfjs左侧pdf菜单组件<template><divclass="pdf-view-list"><divclass="itemactive-item"v-for="(item,index)inpageTotalNum"@click="itemClcik(i......
  • vuedraggable拖拽实现
    1.安装:npmi-Svuedraggable2.引入:importdraggablefrom 'vuedraggable'(在<script>中引用就行)3.代码(简):1<draggable:list="dataList":animation='400'@end="updateMenu">2<transition-group>3......
  • linux释放swap分区内存
    参考文档:https://blog.csdn.net/chenghuikai/article/details/77476830第一步:先执行sync命令#sync第二步:(如果仅仅是清理swap的话,这一步可以不执行)#echo3>/proc/sys/vm/drop_caches说明:**echo1:释放页面缓存echo2:释放目录文件和inodesecho3:释放所有缓存(页面缓存,目录......
  • E325: ATTENTION Found a swap file by the name "/etc/ssh/.sshd_config.swp"
    今天使用vim/etc/ssh/.sshd_config命令报下面这个错误 查询后发现是上次修改内容没有保存,意外退出造成的,生成了一个.swp文件。解决方法1)使用rm-f/etc/ssh/.sshd_config.swp删掉这个备份文件,然后重新编辑2)还原上次编辑结果,使用命令vim-r文件名命令恢复上次编辑结果,使......
  • 仿淘宝京东拖拽商品详情页上下滚动黏滞效果
    比较常用的效果,有现成的,如此甚好!:)importandroid.content.Context;importandroid.content.res.TypedArray;importandroid.support.v4.view.ViewCompat;importandroid.support.v4.view.ViewPager;importandroid.util.AttributeSet;importandroid.vi......
  • python+playwright 学习-57 svg 元素拖拽
    前言SVG英文全称为ScalablevectorGraphics,意思为可缩放的矢量图,这种元素比较特殊,需要通过name()函数来进行定位。本篇讲下关于svg元素的拖拽相关操作。拖拽svg元素如图所示,svg下的circle元素是可以拖动的比如往右拖动100个像素,那么cx的值由原来的cx="100"变成cx="200"通......
  • 在线设计Tkinter界面,生成Python代码,Tkinter布局助手,拖拽生成界面,tkinter designer,可视
    设计地址:https://www.pytk.net/tkinter-helper/? 运行演示  教程地址:https://www.pytk.net/tkinter.html 常用演示"""本代码由[Tkinter布局助手]生成当前版本:3.2.4官网:https://www.pytk.net/tkinter-helperQQ交流群:788392508"""fromtkinterimportmessag......
  • angularjs 拖拽实现方案
    最近有一个拖拽排序的功能遍历后无法直接读取index和item。换了一种思路实现功能<!DOCTYPEhtml><htmllang="en"ng-app="myApp"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,......