Vue · Middle · Question 7 of 75

What is a writable computed?

const fullName = computed({
  get: () => `${first.value} ${last.value}`,
  set: (v) => { [first.value, last.value] = v.split(" "); },
});

Explanation

By default computed refs are read-only. A setter is useful for v-model on derived values; the getter still must be pure.

Further reading

Problem with a question

Vue · Middle · question 7

Test yourself

Take the Vue · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz