组件/SortableList 拖拽排序
通用组件

SortableList 拖拽排序

用于拖拽排序的列表容器(基于 HTML5 Drag & Drop)。

该页面由 AI 迁移生成,请谨慎使用

内容已迁移完成,但仍建议结合源码和人工评审结果使用。

SortableList 拖拽排序

用于拖拽排序的列表容器(基于 HTML5 Drag & Drop)。

import { ref } from 'vue' const list = ref([ { id: 'one', title: 'One' }, { id: 'two', title: 'Two' }, { id: 'three', title: 'Three' }, { id: 'four', title: 'Four' }, ])

基础用法

SortableList

示例即将加载...
<template>
  <TxSortableList v-model="list">
    <template #item="{ item }">
      <div>{{ item.id }}</div>
    </template>
  </TxSortableList>
</template>

API

Props

属性名类型默认值说明
modelValueSortableListItem[]必填列表数据(必须有 id
disabledbooleanfalse禁用拖拽
handlebooleanfalse仅允许在 handle 上拖拽

Events

事件名参数说明
update:modelValue(value)v-model 更新
reorder({ from, to, items })排序完成