Skip to content

Commit 1f28a6b

Browse files
authored
docs: update docs to use defineOptions over requesting a second scrip… (#2384)
1 parent 79b448d commit 1f28a6b

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

src/api/options-misc.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,15 @@ Controls whether the default component attribute fallthrough behavior should be
7676
</div>
7777
<div class="composition-api">
7878

79-
When declaring this option in a component that uses `<script setup>`, a separate `<script>` block is necessary:
79+
When declaring this option in a component that uses `<script setup>`, you can use the [`defineOptions`](/api/sfc-script-setup#defineoptions) macro:
8080

8181
```vue
82-
<script>
83-
export default {
84-
inheritAttrs: false
85-
}
86-
</script>
87-
8882
<script setup>
8983
defineProps(['label', 'value'])
9084
defineEmits(['input'])
85+
defineOptions({
86+
inheritAttrs: false
87+
})
9188
</script>
9289
9390
<template>

src/guide/components/attrs.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,13 @@ If you do **not** want a component to automatically inherit attributes, you can
7979

8080
<div class="composition-api">
8181

82-
If using `<script setup>`, you will need to declare this option using a separate, normal `<script>` block:
82+
If using `<script setup>`, you can use the [`defineOptions`](/api/sfc-script-setup#defineoptions) macro:
8383

8484
```vue
85-
<script>
86-
// use normal <script> to declare options
87-
export default {
88-
inheritAttrs: false
89-
}
90-
</script>
91-
9285
<script setup>
93-
// ...setup logic
86+
defineOptions({
87+
inheritAttrs: false
88+
})
9489
</script>
9590
```
9691

src/guide/extras/composition-api-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Options API does allow you to "think less" when writing component code, which is
106106

107107
### Does Composition API cover all use cases? {#does-composition-api-cover-all-use-cases}
108108

109-
Yes in terms of stateful logic. When using Composition API, there are only a few options that may still be needed: `props`, `emits`, `name`, and `inheritAttrs`. If using `<script setup>`, then `inheritAttrs` is typically the only option that may require a separate normal `<script>` block.
109+
Yes in terms of stateful logic. When using Composition API, there are only a few options that may still be needed: `props`, `emits`, `name`, and `inheritAttrs`.
110110

111111
:::tip
112112

0 commit comments

Comments
 (0)