Vue · Middle · Question 11 of 75

What do defineModel modifiers let you do?

const [model, modifiers] = defineModel({
  set(value) { return modifiers.capitalize ? value.charAt(0).toUpperCase() + value.slice(1) : value; },
});
// parent: <MyInput v-model.capitalize="text" />

Explanation

Destructuring defineModel gives the ref and the modifiers object. get/set options transform values in both directions.

Further reading

Problem with a question

Vue · Middle · question 11

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