Skip to content

Commit 95aabcf

Browse files
Add caveats around mixing <script setup> and <script> (#2149)
1 parent 5e44eeb commit 95aabcf

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/api/sfc-script-setup.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,13 @@ export default {
239239
</script>
240240
```
241241

242+
Support for combining `<script setup>` and `<script>` in the same component is limited to the scenarios described above. Specifically:
243+
244+
- Do **NOT** use a separate `<script>` section for options that can already be defined using `<script setup>`, such as `props` and `emits`.
245+
- Variables created inside `<script setup>` are not added as properties to the component instance, making them inaccessible from the Options API. Mixing APIs in this way is strongly discouraged.
246+
247+
If you find yourself in one of the scenarios that is not supported then you should consider switching to an explicit [`setup()`](/api/composition-api-setup.html) function, instead of using `<script setup>`.
248+
242249
## Top-level `await` {#top-level-await}
243250

244251
Top-level `await` can be used inside `<script setup>`. The resulting code will be compiled as `async setup()`:

0 commit comments

Comments
 (0)