xxxxxxxxxx
<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>
xxxxxxxxxx
import FlashInterface from '@/interfaces/FlashInterface';
import { PropType } from 'vue';
export default {
props: {
message: {
type: Object as PropType<FlashInterface>,
required: true
}
},
setup(props, context) {
// Stuff
}
};
xxxxxxxxxx
<script setup lang="ts">
withDefaults(defineProps<{
title?: string
likes: number,
}>(), {
// here we have default values
title: '---',
})
</script>