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

相关推荐
一颗花生米。19 分钟前
深入理解JavaScript 的原型继承
java·开发语言·javascript·原型模式
学习使我快乐0123 分钟前
JS进阶 3——深入面向对象、原型
开发语言·前端·javascript
bobostudio199524 分钟前
TypeScript 设计模式之【策略模式】
前端·javascript·设计模式·typescript·策略模式
勿语&1 小时前
Element-UI Plus 暗黑主题切换及自定义主题色
开发语言·javascript·ui
一路向前的月光6 小时前
Vue2中的监听和计算属性的区别
前端·javascript·vue.js
长路 ㅤ   6 小时前
vue-live2d看板娘集成方案设计使用教程
前端·javascript·vue.js·live2d
Fan_web6 小时前
jQuery——事件委托
开发语言·前端·javascript·css·jquery
Jiaberrr7 小时前
Element UI教程:如何将Radio单选框的圆框改为方框
前端·javascript·vue.js·ui·elementui
安冬的码畜日常9 小时前
【D3.js in Action 3 精译_029】3.5 给 D3 条形图加注图表标签(上)
开发语言·前端·javascript·信息可视化·数据可视化·d3.js
太阳花ˉ9 小时前
html+css+js实现step进度条效果
javascript·css·html