Use Properties in Vue Components Using @Prop Decorator with TypeScript

Share this video with your friends

Send Tweet

With properties we can follow a one-way parent→child flow communication between components. This lesson shows you how you can pass down properties to class based Vue components by using the @Prop decorator from vue-property-decorator.

We’ll also see how we can set types and even default properties on @Prop!

Jaime Vega
~ 6 years ago

So the the @Prop decorator does not get the type from the TS typescript? It feels like a duplication in your example to define the String type inside the decorator arguments.

And can you do

@Prop({type: Number}) msg: String; 

I know this does not make any sense, I just want to know if it is possible.