Skip to content

Extending Single File Component results to double mounting #10568

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

Closed
itomtom opened this issue Sep 26, 2019 · 1 comment
Closed

Extending Single File Component results to double mounting #10568

itomtom opened this issue Sep 26, 2019 · 1 comment

Comments

@itomtom
Copy link

itomtom commented Sep 26, 2019

Version

2.6.10

Reproduction link

https://codesandbox.io/s/vue-template-rr65f

Steps to reproduce

Run codesandbox and you will see 2 'Created Parent' and 1 'Create Child' console logs.

What is expected?

Only 1 'Create Child' console log

What is actually happening?

Extending the parent template and class is causing extra mounts not required.


What is the correct way for extending Single File Components to reuse template and class?

@posva
Copy link
Member

posva commented Sep 26, 2019

I don't know what you are trying to do by extending the components like that because the template cannot be reused but when it comes to created hooks (as others), they are merged to be both kept (https://vuejs.org/v2/guide/mixins.html#Option-Merging). But basically, only one of them should have a template as only the last one will be used: https://codesandbox.io/s/vue-template-6w60s

To reuse template parts, you should use scoped slots

See #6811 and #5401

@posva posva closed this as completed Sep 26, 2019
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