
Security News
Meet the Socket Team at RSAC and BSidesSF 2025
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.
enn-draggable-list
Advanced tools
拖拽列表组件
借助 vuedraggable 组件实现 https://www.npmjs.com/package/vuedraggable
<template>
<DraggableList :list="list" :selectable="true">
<template #item="{ item }">
<DraggableListItem
:item="item"
@select="onSelect(item)"
@delete="onDelete(item)"
>
{{ item }}
</DraggableListItem>
</template>
</DraggableList>
</template>
<script>
import { DraggableList, DraggableListItem } from '../index';
export default {
components: {
DraggableList,
DraggableListItem,
},
data() {
return {
list: [
{
id: 1,
name: 1,
},
{
id: 2,
name: 2,
},
{
id: 3,
name: 3,
},
{
id: 4,
name: 4,
},
],
};
},
methods: {
onSelect(item) {
console.log('onSelect', item);
},
onDelete(item) {
this.$confirm('确认删除?', null, {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'error',
})
.then(() => {
this.list = this.list.filter((field) => field.id !== item.id);
this.$message({
type: 'success',
message: '已删除',
});
})
.catch(() => {});
},
},
};
</script>
<style>
</style>
<template>
<DraggableTransfer :source="list" v-model="data" />
</template>
<script>
import { DraggableTransfer } from 'enn-draggable-list';
export default {
components: {
DraggableTransfer,
},
data() {
return {
list: [
{
id: 1,
name: 1,
},
{
id: 2,
name: 2,
},
{
id: 3,
name: 3,
},
{
id: 4,
name: 4,
},
],
data: [],
};
},
};
</script>
<style>
</style>
参数 | 类型 | 必填 | 默认值 | 说明 |
---|---|---|---|---|
list | Array | true | 拖拽列表的数据 | |
itemKey | String | 遍历列表项 key 的数据源 | ||
selectable | Boolean | false | 是否开启拖拽触发 select 事件 | |
sortable | Boolean | true | 是否可排序 | |
handle | String | .draggable-list-item .drag-handle | 可拖拽的元素 | |
options | Object | { animation: 200, disabled: false, } | 拖拽相关设置 | |
group | Object\String | 拖拽组设置 | { put: false, push: false, } | |
clone | Function | 当 clone 选项为 true 时,在源组件上调用函数以克隆元素 | ||
listTag | String | 可拖动组件作为包含槽的外部元素创建的元素的 HTML 节点类型 | ||
listData | Object | 将附加信息传递给 listTag 声明的子组件 | ||
itemTag | String | 子组件外部元素创建的元素的 HTML 节点类型 | ||
itemData | Object\Function | 将附加信息传递给 itemTag 声明的子组件型 |
listTag 可拖动组件作为包含槽的外部元素创建的元素的 HTML 节点类型。 也可以将 vue 组件的名称作为元素传递。在这种情况下,draggable 属性将传递给创建组件。 又见 componentData,如果你需要的道具或事件设置为创建的组件。 https://www.npmjs.com/package/vuedraggable#componentdata
clone 当 clone 选项为 true 时,在源组件上调用函数以克隆元素。唯一参数是要克隆的 viewModel 元素,返回值是其克隆版本。 默认情况下 vue.draggable 重用 viewModel 元素,所以如果你想克隆或深度克隆它,你必须使用这个钩子。 https://www.npmjs.com/package/vuedraggable#clone
事件名称 | 说明 | 回调参数 |
---|---|---|
add | 拖拽添加事件 | - |
select | 拖拽选中事件 | - |
名称 | 说明 | 参数 |
---|---|---|
item | 拖拽项的内容 | {item} |
参数 | 类型 | 必填 | 默认值 | 说明 |
---|---|---|---|---|
item | Object | true | 子项的数据 | |
hasControl | Boolean | 是否有控制按钮(拖拽、删除) | ||
active | Boolean | 是否激活,true 时 class 加上 active |
事件名称 | 说明 | 回调参数 |
---|---|---|
select | 选中事件 | - |
delete | 删除事件 | - |
参数 | 类型 | 必填 | 默认值 | 说明 |
---|---|---|---|---|
source | Array | 是 | 左侧拖拽列表的数据 | |
data | Array | 是 | 右侧拖拽列表的数据,使用 v-model 传入 | |
sourceTitle | String | |||
resultTitle | String |
名称 | 说明 | 参数 |
---|---|---|
item | 拖拽项的内容 | {item} |
soureItem | 左侧数据列表拖拽项的内容 | {item} |
resultItem | 右侧结果列表拖拽项的内容 | {item} |
FAQs
The npm package enn-draggable-list receives a total of 1 weekly downloads. As such, enn-draggable-list popularity was classified as not popular.
We found that enn-draggable-list demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.
Security News
Biome's v2.0 beta introduces custom plugins, domain-specific linting, and type-aware rules while laying groundwork for HTML support and embedded language features in 2025.
Security News
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.