Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clickoutside unbind is incorrect if there is multiple clickoutsides #103

Closed
meowtec opened this issue Sep 21, 2016 · 1 comment
Closed

Comments

@meowtec
Copy link
Contributor

meowtec commented Sep 21, 2016

ElementUI version

1.0.0-rc.2

OS/Browers version

macOS/Chrome 53

Vue version

2.0.0-rc.6

Reproduction Link

null

Steps to reproduce

<div class="div1" v-if="show" v-clickoutside="out1"></div>
<div class="div2" v-if="show" v-clickoutside="out2"></div>

execute:

show = false
sleep 100
show = true
sleep 100
show = false
sleep 100
show = true
...

Now click outside div1 and div2

What is Expected?

out1 and out2 will execute only once.

What is actually happening?

out1 and out2 execute many times.


https://github.com/ElemeFE/element/blob/master/src/utils/clickoutside.js

用一个全局的变量 handler 存储 addEventListener 是有问题的。

在 Vue1 中,可以通过 this 访问 Directive 对象,而 Vue2 不行,目前能想到的处理方法是把实例数据挂到当前节点上。

@QingWei-Li
Copy link
Contributor

确实是,忽略这问题了

@meowtec meowtec closed this as completed Sep 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants