0

I want to return null when nothing is selected instead of "". With the reduce function below it still returns "". Note that also if something is selected it needs to return the object but with ONLY the id field in it.

<v-select v-model="answer"
  :placeholder="Pick one (or not)"
  :options="[{id: 1, label: 'A'}, {id: 2, label: 'B'}]"
  :reduce="entry => (entry === '' ? null : {id: entry.id})">
</v-select>
user9645
  • 6,286
  • 6
  • 29
  • 43

1 Answers1

0

Well (duh) the answer is that if they don't select anything, then it doesn't touch the variable referenced in v-model, so it retains whatever value it originally had - which in my case was "". Just initializing it to null fixed everything.

user9645
  • 6,286
  • 6
  • 29
  • 43