Skip to content

What is the best way to structure a component with the new Vue 3 script setup? #6911

Discussion options

You must be logged in to vote

Yeah, pretty much that's it.

The same way we would organize stuff in a class.
imports first, then fields, then getters/setters,
and then methods.

So in a Vue SFC:
imports
Compiler macros (defineProps, defineEmits, definePage (unplugin-vue-router), definePageMeta (Nuxt 3)
props
pinia stores
computed/watchers
life-cycle hooks
methods

Hope I could help. Wishing you health and success. Have fun!

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@LinusBorg
Comment options

Answer selected by JoaoHamerski
Comment options

You must be logged in to vote
2 replies
@libondev
Comment options

@angelhdzdev
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants