Giter Site home page Giter Site logo

Comments (5)

JaguarJack avatar JaguarJack commented on May 28, 2024

遇到同样的问题。目前好像只能把组件做成一个 key:value 对象,拖拽的对象的 component 使用字符串,然后根据对象 key 获取组件渲染 目前正常工作。
但是不知道为啥 clone 的时候不行

from vue-draggable-plus.

JaguarJack avatar JaguarJack commented on May 28, 2024

遇到同样的问题。目前好像只能把组件做成一个 key:value 对象,拖拽的对象的 component 使用字符串,然后根据对象 key 获取组件渲染 目前正常工作。 但是不知道为啥 clone 的时候不行

看了下源码,可能是拷贝的时候使用 JSON.stringify()导致的?还是自己修改 clone 方法吧

from vue-draggable-plus.

LMchensir avatar LMchensir commented on May 28, 2024

遇到同样的问题。目前好像只能把组件做成一个 key:value 对象,拖拽的对象的 component 使用字符串,然后根据对象 key 获取组件渲染 目前正常工作。 但是不知道为啥 clone 的时候不行

看了下源码,可能是拷贝的时候使用 JSON.stringify()导致的?还是自己修改 clone 方法吧

@JaguarJack

我看他这个库提供了一个自定义克隆的属性 :clone 这个属性和 @clone 方法不太一样

image

image

我打印了两个函数的 event 形参(两个参数不一样,handleCustomClone 输出了组件实例)

image

当我使用 :clone 属性定义一个 handleCustomClone 函数,并将 event 形参返回出去后

const handleCustomClone = (event) => { console.log('handleCustomClone_event', event); return event; };

list2就可以使用vue中的动态组件 <component :is="item.component"></component> 来渲染了

image

源码我没有细看,我觉得还是因为 JSON 深拷贝导致的问题,JSON 深拷贝之后的组件是无法渲染出来的

image
image

from vue-draggable-plus.

Alfred-Skyblue avatar Alfred-Skyblue commented on May 28, 2024

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.

JaguarJack avatar JaguarJack commented on May 28, 2024

所以还是建议使用 MAP 映射,{'component': component } 映射, import 到页面中吧,clone 是没办法实现这个的。我目前做了一些尝试,都没有成功。我个人能力有限,放弃了使用 clone,转到 map 映射的方式了

from vue-draggable-plus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.