-
Notifications
You must be signed in to change notification settings - Fork 430
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
[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 |
Maybe it's time that vue-class-component and vue-property-decorator merge into a single tool? It seems like it would be easier to design a better and more wholistic solution this way. |
I totally agree with @theoephraim, I think it would be better and more pragmatic for the class component ecosystem to merge these two libraries. |
I am with you. I use class component style to my project. Don't migrate to Vue 3 until this movement is mature! |
I am migrating to vue 3 . I am not be able to access the props value in my class instead it gives me 0 and not printing in console the latest value i am using on prop. On template it working fine but i want the lateast value of titleComponent in my class[
|
If I omit the constructor, the error message "Uncaught (in promise) TypeError: can't convert undefined to object" does not appear. But I need the constructor because I want to load dependencies here via a container
Installed Packages |
how can i import component in vue-class-component vue 3? @options doesn't work, i do this: nameComponentimport { Options, Vue } from 'vue-class-component'; @options({ and i get empty tag |
counting on v8 official document |
Hi everyone, I have a question. I tried to use Vue3 Extend to build my class base but there will be an error. Can anyone tell me what the problem is? BaseComponent.ts MainComponent.ts |
Please update the documentation: https://class-component.vuejs.org/guide/class-component.html#other-options Came by this post by mistake. It's stuff like this that keeps me (and others from donating). Thanks!!!! |
@ktsn it would be good if you can enable the "discussions" section to move those discussions to the section where it makes more sense. |
any update? |
@loeffel-io, waiting as you. maybe the dont have intention to update this lib. |
We are already migrating every class-component to usual Object options API. Hard thing to do, but we needed to take some decision in order to update to Vue 3 ASAP... I am a bit dissapointed though. Although I appreciate A LOT the work that has been done on this fantastic lib, I would have preferred that the communication about the future of it had been better. I waited months to take the decision pointed above, just because of this lack of clarity. |
@JohnBernardsson going with you! imo the javascript world is wild west, you can never be sure to rewrite the whole thing next week |
Why not migrating to the composition api? What was the reason for migrating from class components to the options API? |
I noticed this comment in the FAQ for Composition API:
I'm sad to see this -- I was a big fan of augmenting vanilla JS (fields, getters, etc) instead of learning a meta language on top -- but it seems that's not the direction the community is going (and for valid advantages). Our team tried refactoring a couple of our components that were written with |
Plus the benefit of the setup attribute inside of the script tag definition to remove the boilerplate code. So at the end, I recommend to test the composition API. It is very easy and you don't need to use the data: {}, props: {} etc. if you use the setup attribute. |
Agree with you guys, Composition API is the right way to go. The only thing I can suggest here, is even the only way I found to face the problem: vc2c (Vue Class 2 Composition) by yoyo930021. I know guys, I know...this cannot be the real solution, neither for me and my company's projects, but I have tried it and it can be a good place to start the conversion of big projects, instead of convert all from scratch. I hope I have helped someone with this comment. |
Actually both vue-class-component and vue-property-decorator already have release candidates with Vue 3 support:
It works well for me and I was able to switch Vue 2 app to Vue 3 (even without the migration build, One catch was that the base It was still a lot of work, since I've also upgraded other related libs - |
At least... that is the plan! :) |
@JohnBernardsson - I'm not sure I understand your strategy. If you just want to get to Vue 3 (& not immediately to Composition), why don't you leave your code as vue-class-component syntax?
Is there some issue with Vue3/VCC that I missing? Stability? |
Hey @charles-allen, some time ago I tried the latest, kind-of Vue-3-ready VCC, I don't remember right now what went wrong, but I had some issues with it. Maybe it was this, or it was when using it with vue-property-decorator (we are using them both) altogether, I don't remember clearly. There are some comments around about "gotchas" of people using those. Also, those "latest" versions are "release candidates" at best. I cannot do a release of a webapp used by dozens of clients (a bunch of them really BIG companies) and thousands of users, with a "release candidate". I really need a production-ready state before going ahead with a migration. |
#406 (comment) |
@SHpiller887 Intermediate components do not work for some reason. import { Vue } from 'vue-class-component'
import { Options } from 'vue-property-decorator'
@Options({})
export default class MyComponent extends Vue {} |
I think @ruojianll 's vue-facing-decorator has a ton of potential...of all the alternatives to the original vue-class-component and vue-property-decorator configs that I've seen so far, that seems to work the best with our existing code with minimal changes. Has anyone else had a chance to check that out? I would love if we could come up with an official vue3 successor to these packages, since the maintainers here don't seem to be responding anymore https://facing-dev.github.io/vue-facing-decorator/ |
there is few thinks missing but we def can make it work, i will most likely spend some time to help folks over there to fix bugs currently atleast in typescript decorators can't affect type of what they are decorating, and that will change with ts5 |
Hello everyone, I have created a vue3 framework with ioc container, named as You can find it here: https://github.com/cabloy/cabloy-front Do you agree with such a concept: Class should not be used in the Therefore, it is completely different from Cabloy-Front has a very important feature: With the support of ioc container, defining reactive states no longer needs Demonstration: no
|
Summary
@Component
will be renamed to@Options
.@Options
is optional if you don't declare any options with it.Vue
constructor is provided fromvue-class-component
package.Component.registerHooks
will move toVue.registerHooks
Example:
Details
As Vue v3 no longer provides base
Vue
constructor, 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
Vue
constructor is we can make@Component
decorator optional. There were non-trivial number of confusions regarding missing@Component
decorator in super class / mixins (e.g. #180). Making decorator optional would solve this problem.Also renaming
@Component
with@Options
would make more sense as it is for adding component options to your class components rather than making a class component.Since
@Options
is optional, havingregisterHooks
on the decorator will not work. So we will move the method under static field ofVue
constructor.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
registerHooks
onVue
.The text was updated successfully, but these errors were encountered: