Comments (5)
遇到同样的问题。目前好像只能把组件做成一个 key:value 对象,拖拽的对象的 component 使用字符串,然后根据对象 key 获取组件渲染 目前正常工作。
但是不知道为啥 clone 的时候不行
from vue-draggable-plus.
遇到同样的问题。目前好像只能把组件做成一个 key:value 对象,拖拽的对象的 component 使用字符串,然后根据对象 key 获取组件渲染 目前正常工作。 但是不知道为啥 clone 的时候不行
看了下源码,可能是拷贝的时候使用 JSON.stringify()
导致的?还是自己修改 clone 方法吧
from vue-draggable-plus.
遇到同样的问题。目前好像只能把组件做成一个 key:value 对象,拖拽的对象的 component 使用字符串,然后根据对象 key 获取组件渲染 目前正常工作。 但是不知道为啥 clone 的时候不行
看了下源码,可能是拷贝的时候使用
JSON.stringify()
导致的?还是自己修改 clone 方法吧
我看他这个库提供了一个自定义克隆的属性 :clone
这个属性和 @clone
方法不太一样
我打印了两个函数的 event 形参(两个参数不一样,handleCustomClone 输出了组件实例)
当我使用 :clone
属性定义一个 handleCustomClone 函数,并将 event 形参返回出去后
const handleCustomClone = (event) => { console.log('handleCustomClone_event', event); return event; };
list2就可以使用vue中的动态组件 <component :is="item.component"></component>
来渲染了
源码我没有细看,我觉得还是因为 JSON 深拷贝导致的问题,JSON 深拷贝之后的组件是无法渲染出来的
from vue-draggable-plus.
Please note that when cloning, the essence is to create a deep copy of the data, and internally, JSON is used for deep copying. This method may result in the loss of certain properties. Additionally, Vue does not recommend placing the constructor of a component into reactive data. Instead, you should construct a map to control the display of a specific component, rather than adding the component's constructor to a ref. If you must use this approach, please pass the "clone" parameter, which accepts a function for you to manually copy it.
from vue-draggable-plus.
所以还是建议使用 MAP 映射,{'component': component } 映射, import 到页面中吧,clone 是没办法实现这个的。我目前做了一些尝试,都没有成功。我个人能力有限,放弃了使用 clone,转到 map 映射的方式了
from vue-draggable-plus.
Related Issues (20)
- nested-component doesn't work HOT 4
- Initiate dragging only on specific child element HOT 3
- Refactor `moveArrayElement` function HOT 1
- 跨组件 clone 会失败 HOT 1
- ant design vue table 指定目标容器 当table 使用 scroll 时,向上拖动时数据会产生 `undefined` HOT 3
- 怎样修改拖曳风格,比如出现一条定位线 HOT 1
- Dual list does not work with getter and setters HOT 4
- How to disabled the first element from being dragged? HOT 2
- 官方文档 - 双列表拖拽 - 【 组件使用 】和【 函数使用 】的示例代码一模一样
- RTL issue
- 克隆 + 双列表拖拽,联合使用时的bug HOT 3
- Drag animation between lists doesn't match drag/drop behavior HOT 1
- 设置 sort 为false 还是能排序 HOT 1
- 当direction="horizontal"时 , 子元素拖动至指定区域外,拖动的子元素位置改变生效,子元素dragend事件失效 HOT 4
- Drag and Drop Outside to a div HOT 1
- Can't figure out how to use with the Primevue Datatable and TreeTable HOT 2
- Moving dynamic components between lists not working, but using cloning works.
- 自定义克隆时,放置的目标顺序错误 HOT 3
- Implementing Restricted Column Movement for Specific Items HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-draggable-plus.