Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-virtual-draglist

Package Overview
Dependencies
Maintainers
1
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-virtual-draglist

一个支持拖拽排序和虚拟滚动的列表组件

  • 2.0.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
362
decreased by-31.83%
Maintainers
1
Weekly downloads
 
Created
Source

可拖拽排序的虚拟滚动列表组件(使用最新版本)

Simple usage

npm i vue-virtual-draglist -D

Root component:

<template>
  <div>
    <virtual-drag-list
      :data-key="'id'"
      :data-source="list"
      @ondragend="ondragend"
    >
      <template #item="{ record, index, dataKey }">
        <span draggable="true">{{ record.id }}</span>
        {{ record.text }}
      </template>
      <template slot="header"></template>
      <template slot="footer"></template>
    </virtual-drag-list>
  </div>
</template>

<script>
  import virtualDragList from 'vue-virtual-draglist'

  export default {
    name: 'root',
    data () {
      return {
        list: [{id: '1', text: 'asd'}, {id: '2', text: 'fgh'}, ...]
      }
    },
    components: { virtualDragList },
    methods: {
      ondragend(list) {
        console.log(list)
      }
    }
  }
</script>

Props type

Required props

PropTypeDescription
data-keyString每一条数据的唯一标识
data-sourceArray数据源

Optional props

Commonly used

PropTypeDefaultDescription
keepsNumber30虚拟滚动展示的数据量
sizeNumber50每一条数据的预估高度,可选择传或不传,会自动计算
draggableBooleantrue默认可拖拽,需要手动指定拖拽元素,设置draggable="true"
Uncommonly used

PropTypeDefaultDescription
headerTagStringdiv顶部插槽的标签类型
footerTagStringdiv底部插槽的标签类型
itemTagStringdivitem的标签类型
itemStyleObject{}item样式
itemClassString''item类名
draggableBooleantrue是否可拖拽
dragStyleObject{ backgroundImage: 'linear-gradient(to bottom, rgba(255, 255, 255, 0.1) 0%, rgba(0, 0, 0, 0.1) 40%, rgba(0, 0, 0, 0.1) 98%, #FFFFFF 100%)' }item样式

Public methods

Usefull public methods

使用 ref 去获取组件内部的方法

MethodDescription
scrollToBottom()滚动到底部
scrollToIndex(index)滚动到指定index值位置
scrollToOffset(offset)滚动到指定高度

Keywords

FAQs

Package last updated on 23 Dec 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc