1

我想通过这个例子有条件地向Quantity组件发送道具。

<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>

如果已激活,我想发送Ordered道具,如果已orderedItems激活则发送。ItemsallItems

4

1 回答 1

1

改用v-bind

<Quantity v-bind="quantityProps" />

然后为此创建一个方法:

quantityProps(item) {
  return {
    [this.allItems ? 'Items' : 'Ordered']: item
  }
}
于 2020-07-16T21:29:09.930 回答