1👍
✅
One way is to use setup script
. This is recommended SFC approach.
- you do not have to reference props from template.
- you do not have to return props, includes, computed, etc. from script
https://vuejs.org/api/sfc-script-setup.html#typescript-only-features
<template>
<div>
<div>Prop: {{ msgProp }}</div>
</div>
</template>
<script setup lang="ts">
import { defineProps, onMounted } from "vue";
interface IDemoProps {
msgProp: string;
}
const props = defineProps<IDemoProps>();
onMounted(() => {
console.log(props)
});
</script>
Source:stackexchange.com