vue2-dragula 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, 0, 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.

原文地址:https://www.cnblogs.com/chenyi4/p/12027603.html

时间: 2024-07-30 15:27:11

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

弹窗拖拽组件开发应用

需要注意的问题包括: 1.this的指向到底是指向谁--弄清楚所指的对象 2.深入理解原型的概念及使用: 去改写对象下面公用的方法或者属性 , 让公用的方法或者属性在内存中存在一份 ( 提高性能) 1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 5 <

自定义事件拖拽组件

<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>自定义事件拖拽组件</title> <style> #div1{ width:100px; height:100px; background:red; position:abs

vue实现拖拽组件

可以拖拽,靠边停靠,效果图如下 代码如下: 注意:代码中使用的图片未上传 DragAndDrop组件: <template> <div class="drag" id="moveDiv" @mousedown="start($event)" @touchstart="start($event)" @mousemove="move($event)" @touchmove="move

Vue 组件总结 (一、拖拽组件 Vue-draggable)

一.vue-draggable 安装使用npm地址: https://www.npmjs.com/package/vuedraggable 二.表格拖拽使用, 举例: <table class="table table-condensed"> <thead> <tr> <th>视频ID</th> <th>名称</th> <th>作者</th> <th>创建时间<

Vue+element 需要用到拖拽组件 vuedraggable

新需求是要求界面上的14个可以拖拽,点击保存之后保存拖拽之后的顺序. 确定需求之后肯定第一时间是百度,发现有个插件vuedragger拖拽,按照教程就懵懂的开始了. 官方示例:https://david-desmaisons.github.io/draggable-example/ 1.安装 npm install vuedraggable 2.引入 import draggable from 'vuedraggable' 3.注册 components: { draggable } html

vue拖拽排序插件vuedraggable的使用 附原生使用方法

Vue中使用 先下载依赖: npm install vuedraggable -S 项目中引入 import draggable from 'vuedraggable' 注册 components: { draggable }, demo: <template> <draggable v-model="colors" @update="datadragEnd" :options = "{animation:500}"> &

Vue拖拽交换数据(非插件)

HelloWorld.vue 文件 <template> <div class="hello"> <h1>{{ msg }}</h1> <div> <div class="team" v-for="(team,tindex) in teamDataArr" :key="tindex"> <div class="member" v-

vue拖拽插件(弹框拖拽)

// =======拖拽 插件 cnpm install vuedraggableimport draggable from 'vuedraggable' <draggable v-model="tags" :move="getdata" @update="datadragEnd"> <transition-group> <div class="testdiv" v-for="eleme

拖拽组件3--转秒味课堂课件

<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>无标题文档</title> <style> #div1{ width:100px; height:100px; background:red; position:absolut