https://github.com/kristianmandrup/vue2-dragula git 地址

https://github.com/kristianmandrup/vue2-dragula-demo/ 安装 并在vue里面使用的详细说明

Drag and drop so simple it hurts

Vue wrapper for dragula drag'n drop library, based on vue-dragula by @Astray-git.

vue 为 dragula 拖拽 包装 减少 代码,基于   vue-dragula

This library has been refactored, upgraded and extended with powerful new features for use with Vue 2.

代码已经被重构了,为vue 2 升级并且延申了有用的新特性

Call for help: copy error 寻求帮助: 拷贝的错误


This library has a long standing issue with the copy operation, resulting in items being inserted twice in the target container.

这个代码有一个长时间存在的问题在拷贝操作上面,导致目标容器里面会把item插入2次。

I have tried to debug it thoroughly but with no success so far. I suspect it has to do with the Vue2 override of Array splicemethod, used in the ModelManager and the correct use of the Vue update queue.

我非常努力的debug修复它,但是目前为止没有成功,我猜测它和Vue2的数组重写 拆分方法有关系,放在在modelManger并且正确的使用了Vue的更新队列。

You can try the ImmutableModelManager and see if that works better as it will return a new immutable array with a new pointer on each change.

你可以尝试 ImmutableModelManager 并且查看 是否可以更好的工作因为它将返回一共新的不可变的数组在 每次更新的时候。

$set for modifying objects in array for reactivity

Vue.set(this.model, changedModel)

Here a JSFiddle to play with

这里是JSFiddle 运行的地方

Please help fix this bug!

请帮助修复这个bug

You can also try a simple array example in a Vue component, with buttons and handlers to simulate each of the effects (on underlying array model) for the drag effects:

你也可以尝试一共简单的数组 例子在Vue 组件中,通过按钮和操作来模拟 每一种拖拽的效果

  • copy
  • move

To better help track and fix the problem with the way Vue updates arrays.

为了更好的帮助跟踪和解决  Vue 更新数组的方式的 问题

insertAt(index, insertModel) {
const splicedModel = this.model.splice(index, , insertModel)
const modelAfterInsert = this.model
return splicedModel
}

Currently the splicedModel returns an empty array [] and modelAfterInsert the same (unmodified) array as before the splice. Yet, copy (or Vue?) still ends up inserting the item twice in the UI

目前 拆分模块返回一个空的数组[] 并且 modelAfterInsert 相同的数组作为之前的拆分。

Copy: ensure clone 拷贝: 确认拷贝 的bug


When making a copy error we need to ensure we are not reusing the same reference in the two container models. We need to clone the value first.

So we should be handling this correctly!?

所以我们确定能正确的解决它么!?

上面就是一些bug 没解决的,下面看下API

API


You can access the global app service via Vue.$dragula.$service or from within a component via this.$dragula.$service(recommended for most scenarios).

你可以获取全局的app 服务 通过  Vue.$dragula.$service 或者在组件里面通过 this.$dragula.$service(推荐使用).

You can also create named services for more fine grained control.

你也可以创建命名的服务为更多的细节控制

Service configuration 服务配置

Set dragula options 设置 dragula 的配置项

Use service.options(name, options) to configure service options

使用 service.options(name, options) 来配置服务配置项

(注册拖拽事件的写法)

// ...
new Vue({
// ...
created () {
const service = Vue.$dragula.$service
service.options('my-drake', {
direction: 'vertical',
})
}
})

find drake by name

Use service.find(name) to return a named drake instance registered with the service.

使用  service.find(name)  来返回一个命名为 drake 被服务所注册的实例。或者这样写

 Vue.vueDragula.options('second-bag', {
copy: true, //拷贝,
containers,
moves,
accepts,
copySortSource
});

属性在 https://github.com/bevacqua/dragula#optionscontainers 所有options.*** 都是可以被放置在{ }里面的属性

Event handlers via event bus 事件处理通过 事件公交车


See drake events

Use service.eventBus.$on to define drake event handlers //通过 eventBus.$on注册事件

service.eventBus.$on('drop', (args) => {
console.log('drop: ' + args[])
})
on('drop')当拖入放下模块的时候
事件列表在https://github.com/bevacqua/dragula#drakeon-events 查看
有 cancel 取消/drag 拖拽/remove 移走

vue2-dragula vue拖拽组件的更多相关文章

  1. vue拖拽组件开发

    vue拖拽组件开发 创建临时vue项目 先查看node和npm版本,怎么安装就不多多bb了 再安装vue-cli npm install vue-cli -g //全局安装 vue-cli 检测是否安 ...

  2. Vue.Draggable:基于 Sortable.js 的 Vue 拖拽组件使用中遇到的问题

    Sortable.js 介绍 https://segmentfault.com/a/1190000008209715 项目中遇到的问题: A - 我需要在项目的拖拽组件中,使用背景 1 - 想到的第一 ...

  3. Vue拖拽组件

    vue开发公众号项目,***产品需要添加一个新的功能.拖拽功能.一听简单.百度上轮子挺多,直接拉一个过来用着就行.然鹅...兴奋之余,却失望至极.东西很多,没有一个能使得.你让我失望,那我就让你绝望. ...

  4. Vue 拖拽组件 vuedraggable 和 vue-dragging

    一.描述 之前用 vue 写过一个在线的多二维码生成服务,体验地址:https://postbird.gitee.io/vue-online-qrcode/ 后面发现二维码多了之后有时候想要排序,需要 ...

  5. Vue拖拽组件列表实现动态页面配置

    需求描述 最近在做一个后台系统,有一个功能产品需求是页面分为左右两部分,通过右边的组件列表来动态配置左边的页面视图,并且左边由组件拼装起来的视图,可以实现上下拖拽改变顺序,也可以删除. 根据这个需求我 ...

  6. Vue 拖拽组件 vuedraggable 和 awe-dnd

    vuedraggable:https://www.npmjs.com/package/vuedraggable awe-dnd:https://www.npmjs.com/package/awe-dn ...

  7. Vue 拖拽组件 vuedraggable 、 vue-dragging 、awe-dnd

    参考链接:http://www.ptbird.cn/vue-draggable-dragging.html vue-draggable 学习和使用:https://www.jianshu.com/p/ ...

  8. Vue 可拖拽组件 Vue Smooth DnD 详解和应用演示

    本文发布自 https://www.cnblogs.com/wenruo/p/15061907.html 转载请注明出处. 简介和 Demo 展示 最近需要有个拖拽列表的需求,发现一个简单好用的 Vu ...

  9. vue-slicksort拖拽组件

    vue-slicksort拖拽组件 安装 通过npm安装 $ npm install vue-slicksort --save 通过yarn安装 $ yarn add vue-slicksort 插件 ...

随机推荐

  1. 【PAT甲级】1006 Sign In and Sign Out (25 分)

    题意: 给出学生人数M,输入M组学生ID,到机房的时间,离开机房的时间.输出最早到机房的学生的ID,空格,最后离开机房的学生的ID.(M大小未给出,就用了1e5) AAAAAccepted code: ...

  2. 「Luogu P3168 [CQOI2015]任务查询系统」

    介绍本题的两种做法: 方法1 前置芝士 线段树:一个很重要的数据结构. 树状数组:一个很重要的数据结构. 具体实现 区间修改,单点查询很容易就会想到树状数组了,至于查询前k个数的和又可以丢给权值线段树 ...

  3. IDEA 打 jar包

    方法一:Maven插件打包(我用此方法解决的问题) 报错:找不到主类Main class,找不到某个依赖的 jar包 解决方法:将未找到的依赖 jar,使用mvn命令打包放入到我们的本地mvn仓库,I ...

  4. SpringMVC 自定义类型转换

    类型转换可以将请求参数转换为指定的类型.指定的格式(数据的格式化),然后传给业务方法的参数. Spring MVC内置了常用的类型转换器.如果内置的类型转换器满足不了需求,可以使用自定义的类型转换. ...

  5. [Linux] day07——查看及过滤文本

    查看及过滤文本 =====================================cat      concatenate         -n 添加行号------------------- ...

  6. python组合数据类型和数据结构

    //2019.12-071.pyhton里面组合数据类型主要有三种:集合(set).序列(字符串str.列表list and 元组tuple)和映射(字典dic)2.集合类型一般使用大括号{}来进行表 ...

  7. leetcode刷题-- 1. 双指针

    这里的题是根据 CS-Notes里的顺序来一步步复习. 双指针 165两数之和 II - 输入有序数组 题目描述 给定一个已按照升序排列 的有序数组,找到两个数使得它们相加之和等于目标数. 函数应该返 ...

  8. 吴裕雄 Bootstrap 前端框架开发——Bootstrap 表格:响应式表格

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  9. 彻底搞懂 JS 中 this 机制

    彻底搞懂 JS 中 this 机制 摘要:本文属于原创,欢迎转载,转载请保留出处:https://github.com/jasonGeng88/blog 目录 this 是什么 this 的四种绑定规 ...

  10. java并发初探ConcurrentHashMap

    java并发初探ConcurrentHashMap Doug Lea在java并发上创造了不可磨灭的功劳,ConcurrentHashMap体现这位大师的非凡能力. 1.8中ConcurrentHas ...