Rawand
Rawand

Reputation: 61

conditionally send props to child element Vue js

I wanna send props to Quantity component conditionally with this example.

<v-card
 class="mx-auto"
 max-width="344"
 shaped
 v-for="(item, index) in allItems || orderedItems"
 :key="index"
>

<Quantity {allItems ? :Items = item : :Ordered = item} />

</v-card>

I want to send Ordered props if orderedItems is Activated and send Items if allItems is activated.

Upvotes: 1

Views: 37

Answers (1)

Ohgodwhy
Ohgodwhy

Reputation: 50777

use v-bind instead:

<Quantity v-bind="quantityProps" />

Then create a method for this:

quantityProps(item) {
  return {
    [this.allItems ? 'Items' : 'Ordered']: item
  }
}

Upvotes: 2

Related Questions