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

相关推荐
摸鱼仙人~6 分钟前
如何设计一个既提供绘图Tools又提供example_data的MCP服务器:
android·服务器·javascript
3Katrina16 分钟前
深入理解 JavaScript 中的柯里化
前端·javascript
BillKu18 分钟前
Vue3 axios 请求设置 signal 信号属性,以便 abort 取消请求
前端·javascript·vue.js
摸鱼仙人~1 小时前
React forwardRef 与 useImperativeHandle 深度解析
前端·javascript·react.js
JohnYan2 小时前
Bun技术评估 - 10 Testing
javascript·后端·bun
onebyte8bits2 小时前
打造丝滑滚动体验:Scroll-driven Animations 正式上线!
前端·javascript·css·html·html5
三脚猫的喵2 小时前
微信小程序使用图片实现红包雨功能
javascript·微信小程序
软件技术NINI3 小时前
html css js网页制作成品——HTML+CSS+js力学光学天文网页设计(4页)附源码
javascript·css·html
独立开阀者_FwtCoder3 小时前
《独立开发工具 • 半月刊》 第 012 期
前端·javascript·github
墨渊君3 小时前
从图片到语音: Kimi 视觉模型与火山引擎的完美结合!
前端·javascript·aigc