Open lzxb opened 1 year ago
This looks very promising. I'll be sure to check it out. Thanks!
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". Does it mean that it's purpose is only to write setup, or can we write components just the same way we do in vue-class-component? I didn't get it right.
One doubt: "Use class style to write setup and support vue2 and vue3". Does it mean that it's purpose is only to write setup, or can we write components just the same way we do in vue-class-component? I didn't get it right.
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 defineComponent
for use, so that type inference can be obtained
It cannot export a class like a class component. It needs to be put into
defineComponent
for use, so that type inference can be obtained
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...
It cannot export a class like a class component. It needs to be put into
defineComponent
for use, so that type inference can be obtainedPerfect! 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