VueJs | Pass For-each Variable to parent Component

Viewed 13

Is it possible to pass the For-Each variable (v-for="item in items" | I wanna pass "item") from a child component to the parent component?

Child component (api-method.vue):

<template>
    <div v-for="object in api" :key="object.id">
    </div>
</template>

Parent Component:

<template>
    <get-api :fetchUrl="passUrl">
        <p> {{ object }} </p> <!-- this isn't working -->
    </get-api>
</template>

<script>
import getApi from "../api-method.vue"

export default {
    components: { getApi },

    data() {
        return {
            passUrl: ...
        }
    }
}
0 Answers
Related