Feature: Vue 3 script setup Alexandru Ghiura on October 16, 2020 I have been doing a lot of Vue.js in the last 6 months and I need to say Vue is awesome. I am coming from “React ❤️ world” but with the release of... Read full post Collapse Expand Denni Denni Denni Follow Location Ukrain Joined Oct 20, 2020 • Oct 22 '20 Dropdown menu Copy link Hide Hi Alexandru Thanks for you post! In vue-2 I set component name like this: <script> const name = 'App'; export default { name, }; </script> Enter fullscreen mode Exit fullscreen mode How can i set component name with 'vue-3 setup syntax? Collapse Expand Alexandru Ghiura Alexandru Ghiura Alexandru Ghiura Follow I am a 🔸 frontend geek, entrepreneur, and father of two sons. ❤️ React & Vue.js. Currently working on AntSignals.com Location Chicago Joined Jun 2, 2019 • Oct 22 '20 Dropdown menu Copy link Hide You can still export default the component: <script setup="props"> // ... other logic here export default { name: 'ComponentName', }; </script> Enter fullscreen mode Exit fullscreen mode Collapse Expand Denni Denni Denni Follow Location Ukrain Joined Oct 20, 2020 • Oct 20 '20 Dropdown menu Copy link Hide What if I want use imported components in SFC? Collapse Expand Alexandru Ghiura Alexandru Ghiura Alexandru Ghiura Follow I am a 🔸 frontend geek, entrepreneur, and father of two sons. ❤️ React & Vue.js. Currently working on AntSignals.com Location Chicago Joined Jun 2, 2019 • Oct 22 '20 Dropdown menu Copy link Hide Hi Denni, A good question, here is an example: <script setup> export { default as Foo } from './Foo.vue' export { default as Bar } from './Bar.vue' export const ok = Math.random() </script> <template> <Foo/> <Bar/> <component :is="ok ? Foo : Bar"/> </template> Enter fullscreen mode Exit fullscreen mode Collapse Expand Denni Denni Denni Follow Location Ukrain Joined Oct 20, 2020 • Nov 5 '20 Dropdown menu Copy link Hide Hi Alexandru, thank you! Collapse Expand bairrada97 bairrada97 bairrada97 Follow I'm a Front End Developer from Lisbon,Portugal Location Lisbon, Portugal Work Front End Developer at Lisbon Joined Sep 11, 2019 • Oct 18 '20 Dropdown menu Copy link Hide What if we want pass arguments on setup? Collapse Expand Alexandru Ghiura Alexandru Ghiura Alexandru Ghiura Follow I am a 🔸 frontend geek, entrepreneur, and father of two sons. ❤️ React & Vue.js. Currently working on AntSignals.com Location Chicago Joined Jun 2, 2019 • Oct 19 '20 Dropdown menu Copy link Hide If you ask how to use emit and other args you pass to setup() function here is an example: <script setup="props, { emit }"> // call emit() here </script> Enter fullscreen mode Exit fullscreen mode Collapse Expand bairrada97 bairrada97 bairrada97 Follow I'm a Front End Developer from Lisbon,Portugal Location Lisbon, Portugal Work Front End Developer at Lisbon Joined Sep 11, 2019 • Oct 19 '20 Dropdown menu Copy link Hide good thats what I wanted to know, thanks Collapse Expand DeFUCC DeFUCC DeFUCC Follow Social impact development Location Moscow, Russia Joined Jan 19, 2021 • Jan 19 '21 Dropdown menu Copy link Hide What about defining emits used in the template with $emit('eventName')? I've found the function defineEmit(), but can't figure out how to use it... Collapse Expand jjclxrk jjclxrk jjclxrk Follow Joined Feb 28, 2021 • Feb 28 '21 Dropdown menu Copy link Hide If anyone else is stuck on this too, I eventually found the answer here: github.com/vuejs/rfcs/pull/227#iss... const emit = defineEmit(['foo']); Enter fullscreen mode Exit fullscreen mode Collapse Expand dajpes dajpes dajpes Follow Joined Oct 25, 2020 • Nov 4 '20 Dropdown menu Copy link Hide what if I want to use async/await? Collapse Expand bairrada97 bairrada97 bairrada97 Follow I'm a Front End Developer from Lisbon,Portugal Location Lisbon, Portugal Work Front End Developer at Lisbon Joined Sep 11, 2019 • Oct 17 '20 • Edited on Oct 17 • Edited Dropdown menu Copy link Hide It looks much more cleaner, gotta give a try Code of Conduct • Report abuse For further actions, you may consider blocking this person and/or reporting abuse
Hi Alexandru
Thanks for you post!
In vue-2 I set component name like this:
How can i set component name with 'vue-3 setup syntax?
You can still
export default
the component:What if I want use imported components in SFC?
Hi Denni,
A good question, here is an example:
Hi Alexandru,
thank you!
What if we want pass arguments on setup?
If you ask how to use
emit
and other args you pass tosetup()
function here is an example:good thats what I wanted to know, thanks
What about defining emits used in the template with $emit('eventName')? I've found the function defineEmit(), but can't figure out how to use it...
If anyone else is stuck on this too, I eventually found the answer here: github.com/vuejs/rfcs/pull/227#iss...
what if I want to use async/await?
It looks much more cleaner, gotta give a try