-
Notifications
You must be signed in to change notification settings - Fork 431
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
I have implemented the class API based on setup, which is friendly to TS types and supports vue2 and vue3 #624
Comments
This looks very promising. I'll be sure to check it out. Thanks! |
Our internal component library is developed based on it |
vue-class-setup正是所需要的。nice! |
Love it - will give it a try |
One doubt: "Use class style to write setup and support vue2 and vue3". |
It is not a class component, but it can use classes to write setup, which can be better supported by TS. |
I have used it on a large scale in our company, involving as many as 100+ projects, and it can run well. |
<script lang="ts">
import { defineComponent } from 'vue';
import { Setup, Context } from 'vue-class-setup';
// Setup and Context must work together
@Setup
class App extends Context {
private _value = 0;
public get text() {
return String(this._value);
}
public set text(text: string) {
this._value = Number(text);
}
public onClick() {
this._value++;
}
}
export default defineComponent({
// Inject setup
...App.inject(),
});
</script>
<template>
<div>
<p>{{ text }}</p>
<button @click="onClick()"></button>
</div>
</template> This is the simplest example, and it is somewhat similar to a class component. |
It cannot export a class like a class component. It needs to be put into |
Perfect! Thank you for clarifying my doubt. Is there any forecast to get official support? I'm afraid of starting to use it, and it just gets abandoned like they did with vue-class-component. I'm starting to migrate my class components to normal ts components because of that... |
There is no official reply at present, but I will maintain it. |
vue-class-component
has been widely used in our projects. vue-class-setup hopes to get official support and further promote the best practices of Vue class. @ktsnSee:
https://github.com/fmfe/vue-class-setup
The text was updated successfully, but these errors were encountered: