2

I get the error above as I am trying to use the v-for directive on a component in a component.

This is working and iterating through some data stored in participants

<template>
    <div
        v-for="(participant, index) in participants"
        v-bind:key="index"
        >
        hello world
    </div>
</template>

But changing to this gives me the above error.

<template>
    <Step1Item
        v-for="(participant, index) in participants"
        v-bind:key="index"
        >
        hello world
    </Step1Item>
</template>

<script>
    import Step1Item from "./Step1Item.vue";

    export default {
        name: "Step1",
        components: Step1Item,
    [...] 
</script>

The component is:

<template>
    <div>
        {{ name }}
    </div>
</template>

<script>
export default {
    name: "Step1Item",
    props: {
        name: String,
    },
};
</script>
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
AndreasInfo
  • 1,062
  • 11
  • 26

1 Answers1

7

You're writing the components option incorrectly, it should be :

 components: {Step1Item},

components option has value as object of componentName:component pairs but you could write it with shorthand syntax components: {component1,component2,...},

Boussadjra Brahim
  • 82,684
  • 19
  • 144
  • 164