Skip to content

Commit

Permalink
Add caveats around mixing <script setup> and <script> (#2149)
Browse files Browse the repository at this point in the history
  • Loading branch information
skirtles-code committed Jan 8, 2023
1 parent 5e44eeb commit 95aabcf
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/api/sfc-script-setup.md
Expand Up @@ -239,6 +239,13 @@ export default {
</script>
```

Support for combining `<script setup>` and `<script>` in the same component is limited to the scenarios described above. Specifically:

- Do **NOT** use a separate `<script>` section for options that can already be defined using `<script setup>`, such as `props` and `emits`.
- 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.

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>`.

## Top-level `await` {#top-level-await}

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

0 comments on commit 95aabcf

Please sign in to comment.