Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
enn-draggable-list-vue3
Advanced tools
拖拽列表组件 for Vue3
借助 vuedraggable 组件实现 https://www.npmjs.com/package/vuedraggable/v/4.1.0
<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 | |||
isClone | Boolean | true | 数据移动的类型 clone / move |
名称 | 说明 | 参数 |
---|---|---|
item | 拖拽项的内容 | {item} |
sourceItem | 左侧数据列表拖拽项的内容 | {item} |
resultItem | 右侧结果列表拖拽项的内容 | {item} |
FAQs
enn-draggable-list-vue3
The npm package enn-draggable-list-vue3 receives a total of 1 weekly downloads. As such, enn-draggable-list-vue3 popularity was classified as not popular.
We found that enn-draggable-list-vue3 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.