Subscribe on changes!

在检查dom包含关系使用contains失效问题

avatar
Nov 30th 2021

Version

3.2.23

Reproduction link

sfc.vuejs.org/

Steps to reproduce

使用动态v-if指令通过document.addEventListener('click', bodyCloseMenus);监听点击事件,导致v-if切换tab以后contains去判断v-if的包含关系的时候没有检测到,造成下拉被关闭

What is expected?

期望可以检测到v-if之间来回切换可以检测dom包含

What is actually happening?

v-if切换到另一个v-if的时候contains失效

avatar
Nov 30th 2021

你可以用vshow, 被删除的元素不会被包含的

avatar
Nov 30th 2021

You are probably looking to write something like vue clickaway: https://www.npmjs.com/package/vue3-click-away

Remember to write issues in English and to use the forum or the Discord chat to ask questions!