Skip to content

Commit 3908106

Browse files
committed
Expanded class components props example
1 parent 7963ad9 commit 3908106

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

class-components.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,33 @@ interface PersonInfo {
7676

7777
@Component
7878
export default class InfoCard extends Vue {
79-
@Prop({ required: true }) readonly info: PersonInfo;
79+
@Prop() readonly info!: PersonInfo;
80+
@Prop({ default: false }) readonly admin?: boolean;
8081
}
8182
</script>
83+
```
84+
Is equivalent to:
85+
86+
```ts
87+
import Vue from "vue-property-decorator";
88+
import Vue, { PropType } from 'vue'
89+
90+
interface PersonInfo {
91+
firstName: string,
92+
surname: string,
93+
age: number
94+
}
95+
export default {
96+
props: {
97+
info: {
98+
type: Object as PropType<PersonInfo>,
99+
required: true
100+
},
101+
admin: {
102+
type: Boolean,
103+
default: false
104+
}
105+
},
106+
}
107+
82108
```

0 commit comments

Comments
 (0)