its my first time in VueJS and we are creating a project in class using typescript. I need to pass the properties of the tabsData variable from the parent component (the view) to the child (the view component). I pass you the code:
<script setup lang="ts">
//import { reactive, ref, computed } from "vue";
import ArgumentTabComponent from "./components/ArgumentTabComponent.vue";
import $t from "@/core/utils/i18n/translate";
import Button from "primevue/button";
import type { IntArgumentListData } from "./types/IntArgumentListData";
const tabsData: IntArgumentListData[] = [
{
title: "Argumento 1",
content: "texto1",
},
{
title: "Argumento 2",
content: "texto2",
},
{
title: "Argumento 3",
content: "texto3",
},
{
title: "Argumento 4",
content: "texto4",
},
{
title: "Argumento 5",
content: "texto5",
},
];
const handleRedirect = () => {
alert("Aceptando!");
};
</script>
<template>
<br />
<h1>Argumentarios</h1>
<div class="">
<ArgumentTabComponent> {{ tabsData }}</ArgumentTabComponent>
<hr />
<Button :label="$t('common.accept')" @click="handleRedirect" />
</div>
</template>
I have been searching a lot on the internet and YouTube but everyone uses export default {} but with TypeScript, I can't do it. What I have tried is to pass the properties as I show you:
<script setup lang="ts">
import TabView from "primevue/tabview";
import TabPanel from "primevue/tabpanel";
// Lib imports
//import { ref } from "vue";
import type { IntArgumentListData } from "../types/IntArgumentListData";
// Properties
const props = defineProps<{
title: IntArgumentListData;
content: IntArgumentListData;
}>();
</script>
<template>
<br />
<div class="">
<TabView>
<TabPanel v-for="tab in props" :key="tab.title" :header="tab.title">
<p>{{ tab.content }}</p>
</TabPanel>
</TabView>
</div>
<br />
</template>
But when using this way I am getting a strange error in the parent component:
So I'm pretty lost. I've spent many hours trying things and thinking about it but I don't understand what I'm doing wrong. Thank you all
Message error in English:
The type '{ tabData: IntArgumentListData[]; "tab data": IntArgumentListData[]; }' cannot be assigned to type 'IntrinsicAttributes & Partial<{}> & Omit<Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{ tabsData: IntArgumentListData[]; }>>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'. Property "tabsData" is missing in type "{ tabData: IntArgumentListData[]; "tab-data": IntArgumentListData[]; }", but is required in type "Omit<Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{ tabsData: IntArgumentListData[ ]; }>>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>".ts(2322)