3.0.0-beta.7
Test.vue
<template>
<span>{{ label }}</span>
</template>
<script lang="ts">
interface TestProps {
label: string;
}
export default {
setup(props: TestProps) {
return { label: props.label };
},
};
</script>
The rendering result of <Test label="hello" /> is empty
Show the string "hello"
The rendering result is empty
This code worked fine a month ago, and no longer work after I update vue.
In addition, I noticed that the test cases related to this feature are commented out. Can you explain the planning of this part?
@yyx990803
The Optional Props Declaration RFC was revoked, and replaced by this active RFC.
@leopiccionia @yyx990803 For TS developers, props must be declared in two places?
interface MyProps {
label: string;
}
export default {
props: {
label: String
},
setup(props: MyProps) {
// ...
},
};
This is very bad for me, hope to have a better solution.
just setup(props), type of props will be inferred
It's strange that stateful components and functional components declare props in different ways, Hope to have a better way like #1155.
Not seeing the solution here. Should props must be declared in two places when using TS ? 馃
Most helpful comment
@leopiccionia @yyx990803 For TS developers, props must be declared in two places?
This is very bad for me, hope to have a better solution.