AhmedAyachi / LinkerLine

An extension to the LeaderLine project: adding parent element,scroll position, absolute parent positioning
MIT License
24 stars 5 forks source link

当我的microApp子应用使用linker-line时,会被抛出一个错误 LeaderLine.js:2 A disconnected element was passed. #9

Open DongZeMan opened 1 day ago

DongZeMan commented 1 day ago

最近开始用microApp整合之前的项目,当嵌入其中一个使用了linkerline的子应用时,控制台抛出来一个错误 image 能告知下是什么原因吗?

AhmedAyachi commented 1 day ago

The first error "a disconnected element was passed" indicates that the start/end element of one of the lines is no longer present in the dom. can you send me a snippet of the code throwing these errors please.

DongZeMan commented 1 day ago

I enclose a picture for you image

AhmedAyachi commented 1 day ago

are you sure you're not removing the elements at some point afterwards ?

DongZeMan commented 1 day ago

是的,但是我目前是作为microapp的子应用,才导致了这个问题,所以想咨询一下有没有什么解决方案

AhmedAyachi commented 1 day ago

still not understood, are you saying there is a bug in linkerline or in the original leader-line project that you would like me to fix it ?

DongZeMan commented 1 day ago

不是的,我只是想知道问题是出在linkerline还是microapp

DongZeMan commented 1 day ago

然后还有就是想知道您有没有碰到过类似问题,如果有的话想请教一下解决方案

AhmedAyachi commented 1 day ago

as you can see the error file is LeaderLine.js, that's the original project code, so the issue is either with your app or leader-line's.

AhmedAyachi commented 1 day ago

yes I did regenerate it just a sec ago, i created a line and after that called line.start.remove() and tried to reposition the line. As I told you, start/end element is no longer in the dom.

DongZeMan commented 1 day ago

但是我当前项目不作为microapp的子应用,这个项目单独运行是没有问题的,并且我自己并没有对dom进行任何操作,所以我也不知道具体问题出在哪边

DongZeMan commented 1 day ago

但是我在new LinkerLine之前对parent,start,end都进行了判断,判断它们都不为null之后,再new LinkerLine,报错还是一样,我也尝试过在setTimeout中去执行,延时为5000ms,依旧是报错,报错内容都一样

AhmedAyachi commented 1 day ago

can you share your code in stackblitz or something similar ?

DongZeMan commented 1 day ago

github仓库可以吗

AhmedAyachi commented 1 day ago

if it's public why not, just send the link

DongZeMan commented 1 day ago

https://github.com/DongZeMan/micro-app-problem-demo.git

DongZeMan commented 1 day ago

代码内容不是最新的,但是同样能复现出对应的效果

AhmedAyachi commented 1 day ago

faced this error App.vue:41 Uncaught TypeError: Cannot read properties of undefined (reading 'addGlobalDataListener') commented line 40-41 in App.vue and the linkerline is getting instantiated. can't see what you're facing exactly. localhost_5678_child1_

DongZeMan commented 1 day ago

因为这个项目我是作为microapp的子系统去嵌入的,您现在应该是单独运行这个项目,所以需要注释掉一些代码,注释掉40行到42行的代码就可以单独运行了,但是我希望的是通过base-project-vite无访问child-project-vite-1,也就是http://localhost:5173/child-app-1这种形式去访问http://localhost:5678,这种方式下则会复现之前的报错

DongZeMan commented 1 day ago

复现步骤是,先运行child-project-vite-1,然后再运行base-project-vite,然后访问http://localhost:5173,再点击第一个菜单,打开控制台就能看到报错了

AhmedAyachi commented 1 day ago

I get it now, when accessing the micro-app server directly np but when accessin it from the base app, it generates that error. It seems to be an issue with the leader-line code itself, same error when using leader-line I guess ?

DongZeMan commented 20 hours ago

如果不使用linkerline,使用leaderline,也会有一模一样的错误

DongZeMan commented 20 hours ago

不管使用leaderline还是linkerline,child-project-vite-1自己单独运行都不会报错

DongZeMan commented 18 hours ago

image 执行new LinkerLine之前都是可以打印出DOM元素的,但是不知道为什么new LinkerLine就开始报错了 image

AhmedAyachi commented 11 hours ago

Then the issue has nothing to do with the linkerline but with the leaderline itself as linkerline is built on top of the latter. I'll try to investigate this, meanwhile, you do the same. But why are you trying to show a subapp inside another app, never seen this tbh.

DongZeMan commented 11 hours ago

好的,最开始我准备询问leaderline的作者,但是leaderline的issue已经不让新建了,所以我没有办法找到作者了,至于为什么要在一个应用程序中显示一个子程序,那是因为我们需要做一个微应用的站点,就是要在主应用中去访问一些接入的子应用程序

AhmedAyachi commented 11 hours ago

can you use an iframe instead and see if that works, just to test it.

DongZeMan commented 11 hours ago

使用iframe嵌入的话,不会报错

DongZeMan commented 11 hours ago

但是我们技术栈要求是microapp