[Vuejs]-Vue 3 Typescript not working properly in template section

0👍

Here is the solution,
I have modified the ComponentA.vue

// ComponentB.vue
<template>
    <ComponentA duration="2.7" />
</template>

and modified ComponentA.vue

<script setup lang="ts">
        
        type ComProps = {
          duration?: '0'|'0.5'|'1'|'1.5'|'2'|'2.5'
        };
        
        const props = defineProps<ComProps>();
    console.log(props.duration)
</script>

Leave a comment