Vue · Senior · Question 72 of 75
How do you keep the initial value of a prop as local editable state without warnings?
const props = defineProps<{ initialTitle: string }>()
const title = ref(props.initialTitle)- ✓Correct answer: Copy it into a local
ref(and name the propinitial*to show it's only a seed) - 2Mutate the prop directly
- 3Use
v-modelon the prop inside the child
Explanation
Later prop changes won't update the copy; if they should, watch the prop or use defineModel instead.