Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

props vue typescript

<script>
// you need npm i vue-property-decorator
import { Component, Prop, Vue } from 'vue-property-decorator'
@Component
export default class HelloWorld extends Vue {
  @Prop() readonly msg!: string
  @Prop({default: 'John doe'}) readonly name: string
  @Prop({required: true}) readonly age: number
  @Prop(String) readonly address: string
  @Prop({required: false, type: String, default: 'Developer'}) readonly job: string
}
</script>
Source by blog.logrocket.com #
 
PREVIOUS NEXT
Tagged: #props #vue #typescript
ADD COMMENT
Topic
Name
5+4 =