[Vuejs]-Can I call a computed in the props of a child component in Vue js

0👍

I don’t quite understand what you are trying to achieve, but I’ll try to help. You seem to want to create a selector that will show you ‘Fruit selected’ when Coconut is selected.

You can’t pass parameters to computed properties. But you could use a method that takes the currently selected fruit and then returns true or false.

You might want to create a custom selector, but it lacks more details about your question. That’s why I used the typical selector here.

<div>Selected: {{ selected }}</div>

<select v-model="selected">
  <option disabled>Please select one</option>
  <option v-for="(item, key) in fruitList" :key="key" :value="item">
    {{ item }}
  </option>
</select>

<FruitSelector :fruitdisplay="getCoconut()" />

And your method:

getCoconut() {
  return this.selected === 'Coconut'
}

Leave a comment