Skip to content

Commit 7681134

Browse files
docs: add note about object/array default values in defineModel (#3410)
* docs: add note about default values in defineModel * Apply suggestions from code review Co-authored-by: Ben Hong <ben@bencodezen.io> --------- Co-authored-by: Ben Hong <ben@bencodezen.io>
1 parent 33ff72a commit 7681134

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

src/api/sfc-script-setup.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ const myRef = ref()
314314
</template>
315315
```
316316

317+
Also, when using `withDefaults` with `defineProps`, default values for mutable reference types (like arrays or objects) should be wrapped in functions in `defineModel` to avoid accidental modification and external side effects.
317318
:::
318319

319320
### Modifiers and Transformers {#modifiers-and-transformers}

src/guide/components/v-model.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ const myRef = ref()
115115
</template>
116116
```
117117

118+
Also, when using `withDefaults` with `defineProps`, default values for mutable reference types (like arrays or objects) should be wrapped in functions in `defineModel` to avoid accidental modification and external side effects.
118119
:::
119120

120121
</div>

0 commit comments

Comments
 (0)