Vue.js Tips: Use Slots The Right Way // VUE.JS SLOTS TUTORIAL WITH VUE 3

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ส.ค. 2024
  • Vue.js has a feature called slots. In this video I discuss how slots work and some tips you should know!
    #vuejs #vuejs3 #learnvue #vueslots
    👉Check out my last video on Vue.js Vuex Killer Pinia
    • Vuex Killer? A Quickst...
    📚 Sign up and get notified about my new Vue 3 course! And get a free cheat sheet! - bit.ly/2vFWBQi
    0:00 Introduction
    0:50 What is the app about
    1:38 Create Child Component
    4:25 Creat slot
    7:03 create scoped slot
    ♡ ♡ ♡
    Make Sure To Check These Courses Out On Udemy! 💻
    → JAVASCRIPT ALGORITHMS COLT STEELE'S COURSE - bit.ly/2L8HSPV
    → THE WEB DEVELOPER BOOTCAMP (GREAT FOR BEGINNERS) - bit.ly/2zP4alw
    👉 Algo expert is the best way to learn algorithms! Check out my code and get 15% off at checkout with code "erik" algoexpert.io/erik
    ___
    Links (and code)
    github.com/ErikCH/SlotExample...
    MY WEBSITE - www.programwitherik.com
    MY TWITTER - / erikch

ความคิดเห็น • 145

  • @ProgramWithErik
    @ProgramWithErik  3 ปีที่แล้ว +3

    📚 Sign up and get notified about my new Vue 3 course! And get a free cheat sheet! - bit.ly/2vFWBQi

  • @RussPainter8
    @RussPainter8 3 ปีที่แล้ว +41

    Very nice. Been using Vue for a while now, but somehow never came across the idea of exposing a child component function this way. One bit of constructive criticism - It would be helpful for beginners if you didn't use variables like "data". It's hard to tell if this is a vue language word, or something they can change. Perhaps a more real world example would lead to better variable names.

    • @svenyboyyt2304
      @svenyboyyt2304 ปีที่แล้ว

      I used to find that hard too. I think names like myVariable are always helpful because it shows it's not fixed or names that are not so generic.

  • @BlackxesWasTaken
    @BlackxesWasTaken ปีที่แล้ว +2

    Not sure if I'm just used to it, but I actually watch almost every educational video about something coding in 1.5 or 2
    since people mostly tend to sway away or drive off topic and do "casual" talk about something none related.
    There are videos prepared with a script beforehand which I set on 1.25, but I actually never watch on 1. Its just simply to slow
    I think educational videos on youtube are mostly beginner or intermediate but never high end stuff.
    I mostly know the basics and intermediate stuff on which I just can "skip" over as in listening to it briefly, understanding everything,
    but this way I can get the gist of a topic or explanation better without losing track because people were like
    "Ah and this (Which is something else) is this and that.. and let me correct this first.. ah wait I forgot.. " etc. You get the point
    Perhaps some people as well just talk slow, sway away or simply introduce artificial delay on purpose to boost the time to a certain length.
    Which is sad as well

  • @scriptedpixelsltd
    @scriptedpixelsltd 3 ปีที่แล้ว +8

    This is good but looking for a use case tbh, it would be great to see some sort of use case where you would use this or have used it in the past

  • @techdan7098
    @techdan7098 3 ปีที่แล้ว

    This was perfect for me. I'm not new to programming but I am new to Vue and this helped solidify what I couldn't grasp from just reading documentation. Thank you!

  • @princechavez
    @princechavez 3 ปีที่แล้ว +9

    Nice content, very informative! I have some minor constructive criticism though: in your example at around 6:30, I think it would help with clarity if you don't name the property name you are declaring the same as the preset vue property (am talkin about the data: () =>{ data: '...' } section). Cheers and more power!

  • @curadermbcc9923
    @curadermbcc9923 2 ปีที่แล้ว

    Very good video!! Finally I understand what are the slots and how they function. It's easy understand them, when someone explains the things fine. Thanks!

  • @piusvictor8780
    @piusvictor8780 3 ปีที่แล้ว +1

    Thanks so much bro,this was one of the concept which confused me alot but now am happy you clear me all the doubts with your simple,clear and brilliant examples,
    One love from Tanzania... Cheers ✨✨

  • @DieterGribnitz
    @DieterGribnitz 2 ปีที่แล้ว

    OMG 2x, did not know this feature existed on youtube. You just cut my research time in half. Thankyou for the tip and thanks for the awesome content.

  • @benjimminy
    @benjimminy 3 ปีที่แล้ว

    OMG. Thank. You. I have read article after article trying to grasp what scoped slots are, and have come away from each one just as confused as I was when I started. I finally get it. I'm struggling at the moment to think of a practical application for scoped slots, but I'm sure that will come now that I understand what they are.

  • @bemi1410
    @bemi1410 3 ปีที่แล้ว

    Vue beginner here, and very grateful for this informative video! Thanks.

  • @pankajs271178
    @pankajs271178 3 ปีที่แล้ว

    One of the Best Slot explaination ... great.. Thanks a lot

  • @chris_ea
    @chris_ea 2 ปีที่แล้ว

    As always, awesome patterns revealed! Thanks!

  • @NigelStratton
    @NigelStratton 3 ปีที่แล้ว

    New with Vue and first time looking at slots. Good amount of info and speed at 1x for following everything.

  • @RockyCastaneda
    @RockyCastaneda ปีที่แล้ว

    Simple examples makes it more understandable. Great job on explaining it to the most simple terms.

  • @isaacgrimaldo8807
    @isaacgrimaldo8807 2 ปีที่แล้ว

    Thank broo, your video helped me in my job, you won a new subscriber today

  • @hakan6379
    @hakan6379 2 ปีที่แล้ว

    theme seems like disco! :D thank you!

  • @hend9745
    @hend9745 3 ปีที่แล้ว

    This was perfect, thank you

  • @rjfortis5415
    @rjfortis5415 3 ปีที่แล้ว

    Great tutorial Erik!

  • @ChrisHaupt
    @ChrisHaupt 2 ปีที่แล้ว

    very useful, thank you!

  • @saturne2248
    @saturne2248 2 ปีที่แล้ว

    Thanks for the video, really helpful.

  • @TecnoRepair
    @TecnoRepair 3 ปีที่แล้ว

    OMG! the best tuto I subscribe right now

  • @EdsonSilva-qr5gr
    @EdsonSilva-qr5gr 3 ปีที่แล้ว

    This is awesome, thank you so much

  • @39zbk13
    @39zbk13 2 ปีที่แล้ว

    great job will help me in my work ;)

  • @jonsplex
    @jonsplex 2 ปีที่แล้ว

    I am one of the people who watch your videos at 2x speed. I don't watch full videos -- I do my best to extract only what I need and move on to my work or another video if I don't get the info that I need.

  • @elimenendez237
    @elimenendez237 3 ปีที่แล้ว

    Thanks a lot!

  • @jntaca
    @jntaca 3 ปีที่แล้ว

    Thanks !!

  •  3 ปีที่แล้ว

    Got stuff Erik! thnks a lot

  • @oshrahartuv4989
    @oshrahartuv4989 ปีที่แล้ว

    Awesome video!! Tnx

  • @notlessgrossman163
    @notlessgrossman163 3 ปีที่แล้ว

    Good format to the point. I pause often to check the code. BTW I was expecting you to tell a real world example to get the 'why' of a feature. I like that you mentioned that the same thing can be done with props and events. I had to check again to confirm the difference I would really like a performance, limits analysis of comparing these options including Rxjs and Vuex.

  • @ruirodrigues705
    @ruirodrigues705 3 ปีที่แล้ว +2

    really nice slot tips! thanks.. :)

  • @nangseakheng2976
    @nangseakheng2976 ปีที่แล้ว

    Love your video 🥰🥰

  • @rishidusad2985
    @rishidusad2985 3 ปีที่แล้ว

    had a diff problem but your video kinda solved it

  • @LofiWurld
    @LofiWurld 3 ปีที่แล้ว

    Amazing!

  • @beedleChompz44
    @beedleChompz44 3 ปีที่แล้ว +3

    Thank you for your video! To answer your question, yes I watch at 2x. Would have loved to see a use case where slots is better than props and emit events! That would have tied it together really nice :)

  • @sergiomassip5731
    @sergiomassip5731 3 ปีที่แล้ว

    Amazing !!

  • @aesmerio
    @aesmerio 3 ปีที่แล้ว +1

    Thanks for the great content =D

  • @rahimeinollahi1
    @rahimeinollahi1 3 ปีที่แล้ว

    thanks man

  • @gatosssss1
    @gatosssss1 3 ปีที่แล้ว

    Starting to learn Vue and i have always wondered how slots work. Seems like it aint so difficult but i probably need some time to think how to use them for an actual web app. Great video btw.

  • @debanjanbarman7212
    @debanjanbarman7212 3 ปีที่แล้ว

    Thanks

  • @tmbarral664
    @tmbarral664 2 ปีที่แล้ว

    yep, watched in x1.5. Used to go for x2.0 but sometimes the sound quality becomes too bad.
    Anyway, your talk speed is perfect. It's just a matter of pref (and allowed time ;) )

  • @fayismahmood8612
    @fayismahmood8612 3 ปีที่แล้ว

    Thnx❤️❤️❤️❤️❤️❤️

  • @silvesterwali6565
    @silvesterwali6565 3 ปีที่แล้ว +1

    Usefull

  • @user-gt1oq6kz6o
    @user-gt1oq6kz6o 2 หลายเดือนก่อน

    thanks

  • @jenstornell
    @jenstornell 3 ปีที่แล้ว

    Speed is perfect and the video is not too easy or hard, for me at least. 👍

  • @rpadron1986
    @rpadron1986 3 ปีที่แล้ว

    the speed for me is 1.25x for your videos, thanks for a cool tips :)

  • @nevinkuser9892
    @nevinkuser9892 ปีที่แล้ว

    What is this styling you're using to make it glow? Really cool! Please share.
    SIDENOTE: I tried watching in 2x and it was too fast. I realized that I was actually robbing myself by watching important videos at 2x because it's WAY harder to retain the information. The problem is patience and focus lol. Studying is painful sometimes, but we need to accept it.
    2x is similar to people using drugs to escape reality. A lot of the time it's not that the presenter is talking too slow, it's that we don't want to be there in the first place.

  • @AlexanderSchaffer72
    @AlexanderSchaffer72 3 ปีที่แล้ว

    just fine, thx!

  • @nero1375
    @nero1375 3 ปีที่แล้ว

    Thanks for this tut!
    Anyway, Did you know why filters are gone on Vue3?

  • @chidieberechukwudi9077
    @chidieberechukwudi9077 3 ปีที่แล้ว

    Lovely. Please what type of vscode theme are you using ?
    I love it

  • @hectorPerez-qf1ho
    @hectorPerez-qf1ho 2 ปีที่แล้ว

    Te amo bro

  • @arkz22
    @arkz22 2 ปีที่แล้ว

    Is there any difference in term of performance when passing data using slot vs emit/props ?
    Thank you for the explanation really like your video.

  • @deirdrechong623
    @deirdrechong623 3 ปีที่แล้ว +1

    Please use composition api when using vue 3

  • @PriyankBolia
    @PriyankBolia 3 ปีที่แล้ว +3

    for me min speed is 2x, generally non programming videos at 3 to 5x, and only music or comedy videos at 1x and 1.5x

    • @ProgramWithErik
      @ProgramWithErik  3 ปีที่แล้ว

      Aww, ok. Yeah I thought that would be too fast, but glad it works

  • @v1r47
    @v1r47 3 ปีที่แล้ว

    Yes, I watch at 1.5. It is good.

    • @v1r47
      @v1r47 3 ปีที่แล้ว

      That was a wonderful tutorial. I never thought it that way!!

  • @devKev34
    @devKev34 3 ปีที่แล้ว

    I didnt think much of slots, but with that functionality i think it's pretty underrated. is that new with vue3?

  • @VitorSouza-uj6ep
    @VitorSouza-uj6ep 2 ปีที่แล้ว

    Hey Erik, what theme do you use in visual studio code? this theme is amazing by the way!

  • @bstark1640
    @bstark1640 3 ปีที่แล้ว +4

    I actually fell in love with the ide theme. What is it?

    • @TheDvscg
      @TheDvscg 3 ปีที่แล้ว +2

      Found it! It's called SynthWave'84 - search for it in the marketplace.

  • @yadusolparterre
    @yadusolparterre 2 ปีที่แล้ว

    I watch your videos in 2x. But don't worry, I watch other videos in 2.5x :)

  • @nadircatalkaya5011
    @nadircatalkaya5011 3 ปีที่แล้ว +1

    I watch your videos at 1.25x speed even if English is not my native language.

  • @mohssinemythe1235
    @mohssinemythe1235 3 ปีที่แล้ว

    Thanks for the great content
    There is any MEVN stack project in the future?

  • @lararawf6100
    @lararawf6100 2 ปีที่แล้ว

    God bless u

  • @Alekobeats
    @Alekobeats 3 ปีที่แล้ว +1

    This should work in Nuxt too right?
    I’ll give it a try. I can see a useful case for this.

  • @sadrashadmand552
    @sadrashadmand552 3 ปีที่แล้ว

    when to use slots vs props for this kind of passing data between child and parent components ?

  • @ahmadalghali90
    @ahmadalghali90 2 ปีที่แล้ว +1

    I watch all tutorials on 2x lol.. including this one

  • @atvoquangthanh8086
    @atvoquangthanh8086 3 ปีที่แล้ว

    What extension do you use to change the theme of vscode? Tks you

  • @kalmanbraz7696
    @kalmanbraz7696 3 ปีที่แล้ว

    Hi! What theme u use for vscode?

  • @MereddynYT
    @MereddynYT 3 ปีที่แล้ว

    I am one of those guys, that watch development videos / tutorials in 1.25 or 1.5. Got used to it.

  • @anveshveerelli9257
    @anveshveerelli9257 ปีที่แล้ว

    Yep I watch in 2x speed, because I will watch each video 5-6times to master.
    So, to read and learn, there are techniques like skimming, scanning, intensive etc.
    Watching your video at 2x speed is like skimming an article....

  • @balenata9359
    @balenata9359 3 ปีที่แล้ว

    bro what theme you use ?

  • @WilliamShrek
    @WilliamShrek 2 ปีที่แล้ว

    I am expecting more slots. ;D. This one is too short.

  • @LukeryaPereprygova
    @LukeryaPereprygova 3 ปีที่แล้ว

    beginner noob question but still - what are a couple of real life practical examples?

  • @dcernach
    @dcernach 3 ปีที่แล้ว

    For me I'm used to watch almost all youtube videos at 1.5x or 1.75x and some at 2x speed !!

  • @ibrahimsule1873
    @ibrahimsule1873 3 ปีที่แล้ว

    I've seen where slots are being used like this and my question is... how is data being retrieved when it's not restructured from an object. From your video, data was restructured from an object.

  • @SebastianNeikes
    @SebastianNeikes 6 หลายเดือนก่อน

    Yes, I'm currently watching this in 1.7x speed.
    But I'm only telling you this because you were curious, that is no critique! If I watch at a slower speed my brain starts wandering off, thinking about other things and loses focus. The best way for me to stay fixated on a video is to increase the speed to force my brain to concentrate.

    • @SebastianNeikes
      @SebastianNeikes 6 หลายเดือนก่อน

      But I've been a developer for quite some time, it's just vue specifics that are new. For example, to get from knowing absolutely nothing about vue to the basics I watched "Vue.js Tutorial: Beginner to Front-End Developer" by "Envato Tuts+" ( /watch?v=1GNsWa_EZdw ) in 2.3x speed on average! (sometimes I slowed to 2x and at most I used 2.4x).
      I hope that insight is interesting

  • @minhtringuyen1267
    @minhtringuyen1267 ปีที่แล้ว

    can u show me some extention used, please.

  • @tontonanton
    @tontonanton 3 ปีที่แล้ว

    to me, it 's valuable only for strongly coupled parent/child components. adds an other layer of complexity to the game, and devs have to keep things as simple as they can. a good modular state managment wouldn't be preferable ?

  • @sadrashadmand552
    @sadrashadmand552 3 ปีที่แล้ว

    2x watcher :-D

  • @OmarAlsaheb
    @OmarAlsaheb 2 ปีที่แล้ว

    As u ask , I watch you on 1,75 :)

  • @danman3196
    @danman3196 2 ปีที่แล้ว

    If I use slot name, it doesn't work . is there a way to fix it ? tks u

  • @klauslife10
    @klauslife10 3 ปีที่แล้ว

    You can pass down a function and handle the click on the child,
    hello = () => alert();

  • @SidharthShambu
    @SidharthShambu 3 ปีที่แล้ว

    Is data passed through slots reactive?

  • @radagast2001
    @radagast2001 2 ปีที่แล้ว

    I have a doubt, I am new at Vue. How can you update child's data? I mean, I have a parent component which uses a child passing a 'data'. When I update parent data, should it be update child's data??

  • @kennethpineda6143
    @kennethpineda6143 3 ปีที่แล้ว +4

    Please make Vuetify tutorial and try there slots.

  • @JeffPohlmeyer
    @JeffPohlmeyer 3 ปีที่แล้ว

    Watching right now in 1.5x, which is a little fast. One I have to watch in at least 1.5 is Ben Awad

  • @odenismata760
    @odenismata760 2 ปีที่แล้ว

    How can I access slotprops from ???

  • @TershiXia
    @TershiXia ปีที่แล้ว

    why your text will be lighting?
    what extension do you use?

  • @jgamer1394
    @jgamer1394 3 ปีที่แล้ว

    Man, should I wait for the official release of vue3 for my project or just use react for now.

    • @StraightCrossing
      @StraightCrossing 3 ปีที่แล้ว

      My experience has been that Vue3 is pretty stable. However if you plan on using TypeScript and the composition API things might be a bit more difficult. Things like vuetify and buefy weren't playing nice and type support for reactive objects seemed to complain with computed properties nested within them. But if you want to use JS you'll probably be fine.

    • @jgamer1394
      @jgamer1394 3 ปีที่แล้ว

      @@StraightCrossing i want to use vuetify and laravel. But base on vuetify roadmap they will release their vue3 version next year

    • @StraightCrossing
      @StraightCrossing 3 ปีที่แล้ว

      @@jgamer1394 yeah all of the component libraries have a lot of work to migrate to Vue 3 which is unfortunate. However you can use CSS libraries like bulma for styling and get most of the way there. But if vuetify is a must I'd wait or start now with Vue 2 then migrate to 3. You shouldn't have to rewrite html to migrate to vue3

  • @michelfonseca3461
    @michelfonseca3461 2 ปีที่แล้ว

    what is this theme?

  • @zacharyallen4270
    @zacharyallen4270 3 ปีที่แล้ว +1

    I've just kind of gotten used to watching tutorials at 2x speed, if I follow along I go slower though.

  • @stevenluoma1268
    @stevenluoma1268 3 ปีที่แล้ว +1

    I watch your videos at 1x speed. You do go fast. I think it's better to just let people use the 2x if they want it to be faster. Slow down is always more awkward than speed up using the youtube feature.

    • @hughmungus1767
      @hughmungus1767 3 ปีที่แล้ว

      Steven Luoma - I am a native English speaker and, honestly, I would not want Erik talking any faster than he already does ;-)

  • @Martin-jq8th
    @Martin-jq8th 2 ปีที่แล้ว

    I'm watching on 1.6x

  • @deload
    @deload 3 ปีที่แล้ว

    2x

  • @johnm8358
    @johnm8358 3 ปีที่แล้ว

    how do i configure the @ to work on import?

    • @ProgramWithErik
      @ProgramWithErik  3 ปีที่แล้ว

      It's by default if you create it with Vue CLI

    • @johnm8358
      @johnm8358 3 ปีที่แล้ว

      @@ProgramWithErik ah that's where I went wrong

  • @lekhrajrai1172
    @lekhrajrai1172 3 ปีที่แล้ว

    which font you are using?

  • @sajjadrahimi1181
    @sajjadrahimi1181 2 ปีที่แล้ว

    what's this guy's vscode theme?

  • @ImanBcheck
    @ImanBcheck 3 ปีที่แล้ว

    1.25

  • @JoeSmith-kn5wo
    @JoeSmith-kn5wo 3 ปีที่แล้ว

    Yes, I watch in 2x speed 😁

  • @matteobagni1235
    @matteobagni1235 3 ปีที่แล้ว

    I watch everything at 1.5

  • @grapes639
    @grapes639 3 ปีที่แล้ว

    Thought Slots were going away with Vue3?

    • @ProgramWithErik
      @ProgramWithErik  3 ปีที่แล้ว +1

      Nope, they are staying, as far as I know.

    • @grapes639
      @grapes639 3 ปีที่แล้ว +1

      @@ProgramWithErik Alright. Good to know :) If I may ask additionally: I thought that "methods" was replaced with "setup" in 3? Or do they serve different purposes?

    • @DedicatedManagers
      @DedicatedManagers 3 ปีที่แล้ว

      Grapes: The “setup” or the “composition” api is purely “additive” meaning it is a bonus feature. The original way (the “options api”) of building components will remain.