DataV-Team / DataV-Vue3

WIP: DataV Vue3 + Vite + TypeScript
https://datav-vue3.jiaminghi.com/
MIT License
348 stars 44 forks source link

[BorderBox*]:报错Cannot read properties of null (reading '$el') #43

Open comWang opened 11 months ago

comWang commented 11 months ago

1.使用了BorderBox组件的页面,卸载时必会出现Cannot read properties of null (reading '$el')错误;

  1. 因此,在使用v-if销毁页面或者keepalive移除缓存页面时,都会出现此问题;
  2. 定位到原因可能是getRefDom方法未对入参ref进行非空判断,因为在上面的1、2情况下,ref的值会是null;
  3. 如果是单独的大屏,没有离开页面的情形,自然不会出现上述情形;
  4. 希望作者能够看到,感谢作者的付出!
ghost commented 11 months ago

如果是用路由跳转到其他页面因为报错跳转不了的 可以在组件销毁前if设置为false 没找到其他方法

Ivanzyh commented 10 months ago

如果是用路由跳转到其他页面因为报错跳转不了的 可以在组件销毁前if设置为false 没找到其他方法

想请教一下具体是怎么做的呢

Txq930530 commented 4 months ago

给这个组件外层包裹一个div,在执行路由导航之前设置div v-if="false"