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

[Suggestion] Vue 2.0 - vm.$appendTo - singleton components #2769

Closed
paulpflug opened this issue Apr 28, 2016 · 3 comments
Closed

[Suggestion] Vue 2.0 - vm.$appendTo - singleton components #2769

paulpflug opened this issue Apr 28, 2016 · 3 comments

Comments

@paulpflug
Copy link

My current singleton pattern is to Vue.extend the component and call $appendTo(body) on compile on the first require and return the vm on all others.

When vm.$appendTo will be removed, I will need another way of creating singleton components..
Maybe something like this:

replace: false
el: => document.body

In vue-comps I have currently 3 singleton components:

  • vue-comps-waves - has a hidden singleton svg store which serves all waves instances with the svg animations
  • vue-toster - the same instance should be shared by all components which use it
  • vue-overlay - a single overlay to black out the background which keeps track of the z-index of all components which use it
@yyx990803
Copy link
Member

I don't quite understand the need for $appendTo() here - you can just use native DOM methods on this.$el, what's the difference?

@paulpflug
Copy link
Author

Maybe I'm just confused about

attached deprecated, components no longer have possibility to be off-dom

Will this work?

Comp = Vue.extend(someComp)
vm = new Comp() # vm is off-dom here ?
document.body.appendChild(vm.$el)

if so, this can be closed..

@yyx990803
Copy link
Member

yyx990803 commented Apr 29, 2016

You need to call $mount() without arguments (which creates vm.$el) before appending it, but otherwise yes it should work.

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

No branches or pull requests

2 participants