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

$destroy() a slot component , the component will not be removed from DOM #5256

Closed
icarusion opened this issue Mar 23, 2017 · 2 comments
Closed

Comments

@icarusion
Copy link

Version

2.2.4

Reproduction link

http://jsbin.com/canofepuyi/edit?html,console

Steps to reproduce

two compoennts: comB and comA, comA as a slot into comB, when use $destroy() in comB to destroy comA, the instance is removed, but dom not.

** in Vue1, it worked. **

What is expected?

dom removed too

What is actually happening?

dom not removed

@zuibunan
Copy link

zuibunan commented Mar 23, 2017

May be I have the same problem !
I use slot too,vue2.2.4
sometimes ,$destroy works well ,but sometimes not , and destroy hooks not triggered too

image

@yyx990803
Copy link
Member

In Vue 2 you should avoid directly manipulating slot children. Instead of $destroying it, you should have a v-if controlling the slot component in the parent:

<comp-b @close-a="showA = false">
  <comp-a v-if="showA"/>
</comp-b>

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

3 participants