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

相关推荐
某公司摸鱼前端43 分钟前
ES13(ES2022)新特性整理
javascript·ecmascript·es13
清幽竹客2 小时前
vue-30(理解 Nuxt.js 目录结构)
前端·javascript·vue.js
weiweiweb8882 小时前
cesium加载Draco几何压缩数据
前端·javascript·vue.js
我不吃饼干9 天前
鸽了六年的某大厂面试题:你会手写一个模板引擎吗?
前端·javascript·面试
我不吃饼干9 天前
鸽了六年的某大厂面试题:手写 Vue 模板编译(解析篇)
前端·javascript·面试
前端fighter9 天前
为什么需要dependencies 与 devDependencies
前端·javascript·面试
满楼、9 天前
el-cascader 设置可以手动输入也可以下拉选择
javascript·vue.js·elementui
嘉琪0019 天前
2025——js 面试题
开发语言·javascript·ecmascript
snow@li9 天前
vue3-ts-qrcode :安装及使用记录 / 配置项 / 效果展示
前端·javascript·vue.js
海天胜景9 天前
vue3 el-table 根据字段值 改变整行字体颜色
javascript·vue.js·elementui