Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
[Vue v3] Changes for @Component decorator and Vue base class #406
Comments
|
Seems some of the breaking changes may not be fully covered with a codemod. |
|
Yes, we can provide a runtime compatibility layer. Just wrapping Maybe providing |
|
Is there a way to already test it with the vuejs/composition-api ?? |
|
I'm going to create a bridge api for composition functions in a separated issue. -> Edit: created #416 |
|
Does the abandonment of the Class API proposal have any affect on this package and whether it would be maintained at the same level in the future? Cheers. |
nope, from what I understand this package will always exist and will always have 1st party package status, its just not practical for the base vue package to use classes in todays world. |
|
@ktsn So we did try the latest vue class component beta and while the new props declaration is working just fine, we need to have Watch, Provide and other related Vue features. The issue is that we were able to access the class variables through |
|
@LifeIsStrange like you, our team share with those concerns. Waiting for an update! |
|
Seems that this new API does not match with documentation https://class-component.vuejs.org which is very confusing. |
|
@LifeIsStrange I think having Watch and Provide and other decorators for class methods and fields are part of vue-property-decorators, isn't it? Already mentioned in the documentation: |
|
@Chris2011 |
|
@LifeIsStrange well, vue-property-decorator depends on vue-class-component, so I guess they will farely wait for the new version 8 of this package here. :). Just my opinion, no insides. |
|
Hope this situation changes. This two libs belongs to the top of mind of the Vue community! |
|
@Chris2011 that's not how it should work, they should begin working on it while it's in beta. If they need to do some breaking changes to vue class component it will be too late after a stable release |
|
how can we modify a msg in watch method like that
|
|
@ZhengXingchi this cannot be used in arrow functions, the following code is work |



Summary
@Componentwill be renamed to@Options.@Optionsis optional if you don't declare any options with it.Vueconstructor is provided fromvue-class-componentpackage.Component.registerHookswill move toVue.registerHooksExample:
Details
As Vue v3 no longer provides base
Vueconstructor, Vue Class Component will provide it instead. Fortunately, we can add class component specific features in the base class as we define it in Vue Class Component package.One of the benefits with the new
Vueconstructor is we can make@Componentdecorator optional. There were non-trivial number of confusions regarding missing@Componentdecorator in super class / mixins (e.g. #180). Making decorator optional would solve this problem.Also renaming
@Componentwith@Optionswould make more sense as it is for adding component options to your class components rather than making a class component.Since
@Optionsis optional, havingregisterHookson the decorator will not work. So we will move the method under static field ofVueconstructor.Alternative approach
Declaring component options as static properties
We could do this to define class component options:
But it has a drawback: we cannot define static properties / methods not for component options both on userland and library side. e.g. we cannot define static method like
registerHooksonVue.The text was updated successfully, but these errors were encountered: