-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
How about creating subviews with Vue? #146
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
Comments
If you want, you can totally do something similar in Vue.js: this.subVue = new SubVue({
data: this.someDataToInherit
}).$appendTo(this.$el)
// later
this.subVue.$destroy() This is only necessary when you have super heavy views and you want to explicitly control the lifecycle of the sub view for better memory management. In most cases, you can just compose everything together and use |
@yyx990803 It would be so nice if we could have an option to tell Vue that subVue is a child of this and therefore able to $dispatch messages and catch $broadcast-ed messages in the hierarchy of VMs. |
@marfalkov that's a good point. I do have an internal compiler option that does this... it just occurred to me that I should make it a public option: 0893163 So the above example could be: this.subVue = new SubVue({
parent: this,
data: this.someDataToInherit
}).$appendTo(this.$el)
// later
this.subVue.$destroy() And you'd get all the benefits: access to |
@yyx990803 Great! |
It confused me quite long time since I know MVVM, as a developer based on Backbone.
In Backbone, when new views are required, we just do
and remove that subView when it disappears:
So in such a case in the picture below, I would just open
View 1
by clickingButton 1
,and click
Button A
to openContext I
..How do people build such kind of UI in Vue?
The text was updated successfully, but these errors were encountered: