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

Add lifecycle hooks for v-show change #7033

Closed
niutech opened this Issue Nov 10, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@niutech

niutech commented Nov 10, 2017

What problem does this feature solve?

There is no easy way to create a callback when the v-show condition changes and the component is shown/hidden. Using watchers is sufficient only for a single property in v-show, but it's cumbersome when the condition is like v-show="a < 1 && !b || c > 2". So I propose to add a new pair of lifecycle hooks (events): shown and hidden.

What does the proposed API look like?

shown() {
    console.log('The component is shown')
}
hidden() {
    console.log('The component is hidden')
}
@yyx990803

This comment has been minimized.

Show comment
Hide comment
@yyx990803

yyx990803 Nov 10, 2017

Member

v-show in its current implementation simply need to toggle a style property on a single element. Making it recursively invoke hooks on components contained inside the element makes it exponentially more complex for marginal benefits. Just use a computed property for your v-show condition instead.

Member

yyx990803 commented Nov 10, 2017

v-show in its current implementation simply need to toggle a style property on a single element. Making it recursively invoke hooks on components contained inside the element makes it exponentially more complex for marginal benefits. Just use a computed property for your v-show condition instead.

@yyx990803 yyx990803 closed this Nov 10, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment