vuedraggable的使用

安装

javascript 复制代码
yarn add vuedraggable
npm i -S vuedraggable

使用

js引入

javascript 复制代码
import draggable from 'vuedraggable'

components: {
    draggable,
  },

html

javascript 复制代码
<v-list>
  <draggable :list="newHeaderList">
    <v-list-item v-for="item in newHeaderList" :key="item.value">
      <v-list-item-action>
        <v-checkbox v-model="item.checked" color="primary"></v-checkbox>
      </v-list-item-action>
      <v-list-item-title>{{ item.text }}</v-list-item-title>
    </v-list-item>
  </draggable>
</v-list>

newHeaderList

javascript 复制代码
[
    {
        "checked": true,
        "text": "a",
        "value": "vin",
        "sortable": false,
        "width": "100px"
    },
    {
        "checked": true,
        "text": "id",
        "value": "id",
        "width": "100px"
    },
    {
        "checked": true,
        "text": "描述",
        "value": "description",
        "width": "200px"
    },
    {
        "checked": true,
        "text": "状态",
        "value": "status",
        "width": "100px"
    },
    {
        "checked": true,
        "text": "级别",
        "value": "level",
        "width": "80px"
    },
    {
        "checked": true,
        "text": "资产",
        "value": "asset",
        "width": "100px"
    },
    {
        "checked": false,
        "text": "车型",
        "value": "vehicle",
        "width": "150px",
        "class": "display-none",
        "cellClass": "display-none"
    },
    {
        "checked": false,
        "text": "分类",
        "value": "type",
        "sortable": false,
        "width": "200px",
        "class": "display-none",
        "cellClass": "display-none"
    },
    {
        "checked": false,
        "text": "时间",
        "value": "date",
        "width": "195px",
        "class": "display-none",
        "cellClass": "display-none"
    },
    {
        "checked": false,
        "text": "创建者",
        "value": "createUser",
        "width": "120px",
        "class": "display-none",
        "cellClass": "display-none"
    },
    {
        "checked": false,
        "text": "更新者",
        "value": "updateUser",
        "width": "120px",
        "class": "display-none",
        "cellClass": "display-none"
    },
]

参考连接

npm官网:https://www.npmjs.com/package/vuedraggable

sortablejs官网:https://sortablejs.github.io/Vue.Draggable/#/simple

相关文章:https://juejin.cn/post/6844904062488412173

简单使用:https://github.com/SortableJS/Vue.Draggable/blob/master/example/components/simple.vue

相关推荐
FogLetter1 天前
当JavaScript学会“分身术”:异步编程的进化简史
前端·javascript·面试
java1234_小锋1 天前
Vue3+Vite简介以及构建第一个HelloWorld实例
前端·javascript·vue.js·vite
天天鸭1 天前
5 万处中文的老项目实现国际化,如何用架构思维完成改造?
前端·javascript·架构
月月大王的3D日记1 天前
Three.js 入门系列(7):让甜甜圈围着我转 —— 3D文字生成
前端·javascript
半兽先生1 天前
深度对比:Mapbox GL JS vs Maptalks,WebGIS 开发该如何选型?
开发语言·javascript·ecmascript
only-lucky1 天前
QML深入学习五(Controls模块)
前端·javascript·学习
其美杰布-富贵-李1 天前
第 5 篇:Object3D、Group 与场景树
javascript·three.js
海带紫菜菠萝汤1 天前
H.264 宏块划分与码率分配机制:影响压缩效率的关键参数详解
前端·javascript·音视频
mONESY1 天前
React + TypeScript 入门到进阶:从 Props 类型约束到状态管理与副作用最佳实践
javascript
码哥DFS1 天前
算法练习day1-备战2027届秋招
前端·javascript·数据结构·算法