Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

180
Visualizações
Typscript: How do I Call Nested Array on Vue Data?

I created an interface with the code below:

export interface ISubcategories {
    subCategoryTopic: string;
    subCategoryImageURL: string;
    subCategoryImage: ISubcategoryImages[];
}

export interface ISubcategoryImages {
    podcastImageURL: string;
    videoImageURL: string;
    articleImageURL: string;
}

export interface ICategories {
    categoryTopic: string;
    subCategory: ISubcategories[];
}

I called it in the data section of my vuejs code with:

categoryData: {
  categoryTopic: "" as string,
  subCategory: [] as Array<ISubcategories>,
},

However, when I do add the code below to the textbox where I want the data to be, I get this error :

_vm.categoryData.subCategory.subCategoryImage is undefined.

What should I do ?

v-model="categoryData.subCategory.subCategoryImage.podcastImageURL"
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

One observation : As subCategory & subCategoryImage in interface ISubcategories is defined as an array. You can not access it's object directly with dot(.) notation. You can access elements via index or by iteration.

For ex :

<div v-for="(subCat, index) in categoryData.subCategory" :key="index">
    <div v-for"(imageUrl, i) in subCat.subCategoryImage" :key="i">
        <input v-model="imageUrl.podcastImageURL"/>
    </div>
</div>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda