Skip to content

witDraggable Draggable Sort Component

witDraggable is a draggable sort component based on Sortable.js, suitable for Vue 3 projects. The component supports list drag sorting, add, remove and other operations, provides rich events and configuration options, can be used to implement drag sorting interaction functionality.

Usage Example

vue
<template>
  <div>
    <witDraggable
      v-model="listData"
      :item-key="'id'"
      :tag="'ul'"
    >
      <li v-for="item in listData" :key="item.id">
        {{ item.name }}
      </li>
    </witDraggable>
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'

// List data
const listData = ref([
  { id: 1, name: 'Item 1' },
  { id: 2, name: 'Item 2' },
  { id: 3, name: 'Item 3' },
  { id: 4, name: 'Item 4' },
  { id: 5, name: 'Item 5' }
])
</script>

API

Component

Component NameDescription
witDraggableDraggable sort main component

Properties

Property NameTypeDefault ValueDescription
listArraynullData list (choose one with modelValue)
modelValueArraynullData list (v-model two-way binding)
itemKeyString/FunctionNoneUnique identifier for list items, required

湘ICP备2024070110号