Skip to content

Commit d31fa1f

Browse files
committed
Moved over section re: props and class components over from readme.md
1 parent 39c0be5 commit d31fa1f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

class-components.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Class Components
2+
3+
## Overview
4+
25
[Vue Class Components](https://class-component.vuejs.org/) offers an alternative class-style syntax for Vue components which integrates well with TypeScript.
36

47
To have consistent support for decorators in your Vue components, it's also recommended to install [vue-property-decorator](https://github.com/kaorun343/vue-property-decorator).
@@ -57,3 +60,23 @@ export default class Hello extends Vue {
5760
See the [full guide for Vue Class Components](https://class-component.vuejs.org/guide/class-component.html#data).
5861

5962
> _Class components should not confused with the now abandoned [Class API proposal](https://github.com/vuejs/rfcs/pull/17#issuecomment-494242121)._
63+
64+
## Props
65+
You can use the `Prop` decorator to annoate your prop types like so:
66+
67+
```ts
68+
<script lang="ts">
69+
import { Vue, Component, Prop } from "vue-property-decorator";
70+
71+
interface PersonInfo {
72+
firstName: string,
73+
surname: string,
74+
age: number
75+
}
76+
77+
@Component
78+
export default class InfoCard extends Vue {
79+
@Prop({ required: true }) readonly info: PersonInfo;
80+
}
81+
</script>
82+
```

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy