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

相关推荐
echoVic4 分钟前
多模型支持的架构设计:如何集成 10+ AI 模型
java·javascript
echoVic8 分钟前
AI Agent 安全权限设计:blade-code 的 5 种权限模式与三级控制
java·javascript
David凉宸10 分钟前
Vue 3 + TS + Vite + Pinia vs Vue 2 + JS + Webpack + Vuex:对比分析
javascript·vue.js·webpack
boooooooom21 分钟前
Pinia必学4大核心API:$patch/$reset/$subscribe/$onAction,用法封神!
javascript·vue.js·面试
不会敲代码135 分钟前
解密JavaScript内存机制:从执行上下文到闭包的全景解析
javascript
NEXT0641 分钟前
React Hooks 进阶:useState与useEffect的深度理解
前端·javascript·react.js
踢足球09291 小时前
寒假打卡:2026-2-7
java·开发语言·javascript
楚轩努力变强2 小时前
iOS 自动化环境配置指南 (Appium + WebDriverAgent)
javascript·学习·macos·ios·appium·自动化
John_ToDebug2 小时前
引擎深处的漫游者:构建浏览器JavaScript引擎的哲学与技艺
javascript·chrome·js
程序猿阿伟2 小时前
《TypeScript中Protobuf到运行时类型安全的转换指南》
javascript·安全·typescript