vue3-dnd icon indicating copy to clipboard operation
vue3-dnd copied to clipboard

Invariant Violation: Expected drag drop context

Open Gaoxw5711 opened this issue 1 year ago • 7 comments

Why do I use dnd to report an error in my application, is there a problem with the usage method, and how can I adjust it? image image

Gaoxw5711 avatar Aug 13 '23 17:08 Gaoxw5711

First of all, you should first confirm whether the DndProvider is used in the upper component and the correct attributes are passed If you are sure that there is no problem with the above steps, but you still encounter the above error, you can check whether there are two vue-demi in node_modules at the same time (for example, vueuse and vue3-dnd are installed at the same time), or exist at the same time Two different versions of vue etc. If you encounter such a problem, I suggest you use pnpm install to solve it

hcg1023 avatar Aug 14 '23 02:08 hcg1023

我也出现了这个问题,我使用的是pnpm install,我的项目里面的确有vueuse

LIUSHUAI2018 avatar Sep 14 '23 09:09 LIUSHUAI2018

我也出现了这个问题,我使用的是pnpm install,我的项目里面的确有vueuse

可以检查一下,看看是不是安装了两个不同版本的vue

hcg1023 avatar Sep 14 '23 10:09 hcg1023

image

image

我也出现了这个问题,我使用的是pnpm install,我的项目里面确实有vueuse

可以检查一下,看看是不是安装了两个不同版本的vue

LIUSHUAI2018 avatar Sep 15 '23 00:09 LIUSHUAI2018

我也出现了这个问题,我使用的是pnpm install,我的项目里面确实有vueuse

可以检查一下,看看是不是安装了两个不同版本的vue

这个是个非常简单的实例,除了vue和vuednd没有其他依赖 image

LIUSHUAI2018 avatar Sep 15 '23 00:09 LIUSHUAI2018

你这段代码出现这个的原因在于,你的DndProvider没有放到上层组件,或者你把drop封装成一个单独的组件,DndProvider和useDrop/useDrag/useDragLayer在同一个组件内时,确实会出现这种问题,原因是provider和inject找的是上层组件,而不是当前组件 @LIUSHUAI2018

hcg1023 avatar Sep 15 '23 01:09 hcg1023

可能代码出现这个问题的原因是,你的DndProvider没有放到上层组件,或者你把drop封装做成一个单独的组件,DndProvider和useDrop/useDrag/useDragLayer在同一个组件内时,确实会出现这种问题,原因是provider和inject找的是上层组件,而不是当前组件@LIUSHUAI2018

ok了

LIUSHUAI2018 avatar Sep 15 '23 02:09 LIUSHUAI2018