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

Sdílet
Vložit
  • čas přidán 28. 07. 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

Komentáře • 145

  • @ProgramWithErik
    @ProgramWithErik  Před 3 lety +3

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

  • @RussPainter8
    @RussPainter8 Před 3 lety +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 Před rokem

      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 Před rokem +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 Před 3 lety +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 Před 3 lety

    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!

  • @curadermbcc9923
    @curadermbcc9923 Před 2 lety

    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 Před 3 lety +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 ✨✨

  • @NigelStratton
    @NigelStratton Před 3 lety

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

  • @chris_ea
    @chris_ea Před 2 lety

    As always, awesome patterns revealed! Thanks!

  • @bemi1410
    @bemi1410 Před 3 lety

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

  • @pankajs271178
    @pankajs271178 Před 3 lety

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

  • @DieterGribnitz
    @DieterGribnitz Před 2 lety

    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.

  • @saturne2248
    @saturne2248 Před 2 lety

    Thanks for the video, really helpful.

  • @hend9745
    @hend9745 Před 3 lety

    This was perfect, thank you

  • @benjimminy
    @benjimminy Před 3 lety

    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.

  • @princechavez
    @princechavez Před 3 lety +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!

  • @TecnoRepair
    @TecnoRepair Před 3 lety

    OMG! the best tuto I subscribe right now

  • @isaacgrimaldo8807
    @isaacgrimaldo8807 Před 2 lety

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

  • @EdsonSilva-qr5gr
    @EdsonSilva-qr5gr Před 3 lety

    This is awesome, thank you so much

  • @rjfortis5415
    @rjfortis5415 Před 3 lety

    Great tutorial Erik!

  • @notlessgrossman163
    @notlessgrossman163 Před 3 lety

    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.

  • @ChrisHaupt
    @ChrisHaupt Před 2 lety

    very useful, thank you!

  • @oshrahartuv4989
    @oshrahartuv4989 Před rokem

    Awesome video!! Tnx

  • @39zbk13
    @39zbk13 Před 2 lety

    great job will help me in my work ;)

  • @hakan6379
    @hakan6379 Před 2 lety

    theme seems like disco! :D thank you!

  • @RockyCastaneda
    @RockyCastaneda Před rokem

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

  • @elimenendez237
    @elimenendez237 Před 3 lety

    Thanks a lot!

  •  Před 3 lety

    Got stuff Erik! thnks a lot

  • @ruirodrigues705
    @ruirodrigues705 Před 3 lety +2

    really nice slot tips! thanks.. :)

  • @nangseakheng2976
    @nangseakheng2976 Před rokem

    Love your video 🥰🥰

  • @aesmerio
    @aesmerio Před 3 lety +1

    Thanks for the great content =D

  • @jntaca
    @jntaca Před 3 lety

    Thanks !!

  • @sergiomassip5731
    @sergiomassip5731 Před 3 lety

    Amazing !!

  • @rishidusad2985
    @rishidusad2985 Před 3 lety

    had a diff problem but your video kinda solved it

  • @LofiWurld
    @LofiWurld Před 3 lety

    Amazing!

  • @icarofreitas6523
    @icarofreitas6523 Před 2 lety

    Thanks

  • @nero1375
    @nero1375 Před 3 lety

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

  • @chidieberechukwudi9077

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

  • @gatosssss1
    @gatosssss1 Před 3 lety

    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.

  • @rahimeinollahi1
    @rahimeinollahi1 Před 3 lety

    thanks man

  • @arkz22
    @arkz22 Před 2 lety

    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.

  • @silvesterwali6565
    @silvesterwali6565 Před 3 lety +1

    Usefull

  • @user-gt1oq6kz6o
    @user-gt1oq6kz6o Před 2 měsíci

    thanks

  • @fayismahmood8612
    @fayismahmood8612 Před 3 lety

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

  • @VitorSouza-uj6ep
    @VitorSouza-uj6ep Před 2 lety

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

  • @atvoquangthanh8086
    @atvoquangthanh8086 Před 3 lety

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

  • @tmbarral664
    @tmbarral664 Před 2 lety

    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 ;) )

  • @jenstornell
    @jenstornell Před 3 lety

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

  • @rpadron1986
    @rpadron1986 Před 3 lety

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

  • @kalmanbraz7696
    @kalmanbraz7696 Před 3 lety

    Hi! What theme u use for vscode?

  • @AlexanderSchaffer72
    @AlexanderSchaffer72 Před 3 lety

    just fine, thx!

  • @devKev34
    @devKev34 Před 3 lety

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

  • @beedleChompz44
    @beedleChompz44 Před 3 lety +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 :)

  • @sadrashadmand552
    @sadrashadmand552 Před 3 lety

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

  • @balenata9359
    @balenata9359 Před 3 lety

    bro what theme you use ?

  • @deirdrechong623
    @deirdrechong623 Před 3 lety +1

    Please use composition api when using vue 3

  • @hectorPerez-qf1ho
    @hectorPerez-qf1ho Před 2 lety

    Te amo bro

  • @Alekobeats
    @Alekobeats Před 3 lety +1

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

  • @jonsplex
    @jonsplex Před 2 lety

    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.

  • @minhtringuyen1267
    @minhtringuyen1267 Před rokem

    can u show me some extention used, please.

  • @danman3196
    @danman3196 Před 2 lety

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

  • @mohssinemythe1235
    @mohssinemythe1235 Před 3 lety

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

  • @nevinkuser9892
    @nevinkuser9892 Před rokem

    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.

  • @SidharthShambu
    @SidharthShambu Před 3 lety

    Is data passed through slots reactive?

  • @michelfonseca3461
    @michelfonseca3461 Před 2 lety

    what is this theme?

  • @bstark1640
    @bstark1640 Před 3 lety +4

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

    • @TheDvscg
      @TheDvscg Před 3 lety +2

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

  • @odenismata760
    @odenismata760 Před 2 lety

    How can I access slotprops from ???

  • @v1r47
    @v1r47 Před 3 lety

    Yes, I watch at 1.5. It is good.

    • @v1r47
      @v1r47 Před 3 lety

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

  • @PriyankBolia
    @PriyankBolia Před 3 lety +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  Před 3 lety

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

  • @LukeryaPereprygova
    @LukeryaPereprygova Před 3 lety

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

  • @sajjadrahimi1181
    @sajjadrahimi1181 Před 2 lety

    what's this guy's vscode theme?

  • @tontonanton
    @tontonanton Před 3 lety

    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 ?

  • @TershiXia
    @TershiXia Před rokem

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

  • @lararawf6100
    @lararawf6100 Před 2 lety

    God bless u

  • @johnm8358
    @johnm8358 Před 3 lety

    how do i configure the @ to work on import?

    • @ProgramWithErik
      @ProgramWithErik  Před 3 lety

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

    • @johnm8358
      @johnm8358 Před 3 lety

      @@ProgramWithErik ah that's where I went wrong

  • @lekhrajrai1172
    @lekhrajrai1172 Před 3 lety

    which font you are using?

  • @ibrahimsule1873
    @ibrahimsule1873 Před 3 lety

    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.

  • @radagast2001
    @radagast2001 Před 2 lety

    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??

  • @jgamer1394
    @jgamer1394 Před 3 lety

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

    • @StraightCrossing
      @StraightCrossing Před 3 lety

      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 Před 3 lety

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

    • @StraightCrossing
      @StraightCrossing Před 3 lety

      @@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

  • @MereddynYT
    @MereddynYT Před 3 lety

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

  • @ImanBcheck
    @ImanBcheck Před 3 lety

    1.25

  • @sadrashadmand552
    @sadrashadmand552 Před 3 lety

    2x watcher :-D

  • @SebastianNeikes
    @SebastianNeikes Před 6 měsíci

    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 Před 6 měsíci

      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

  • @dcernach
    @dcernach Před 3 lety

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

  • @nadircatalkaya5011
    @nadircatalkaya5011 Před 3 lety +1

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

  • @WilliamShrek
    @WilliamShrek Před 2 lety

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

  • @anveshveerelli9257
    @anveshveerelli9257 Před rokem

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

  • @ahmadalghali90
    @ahmadalghali90 Před 2 lety +1

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

  • @kennethpineda6143
    @kennethpineda6143 Před 3 lety +4

    Please make Vuetify tutorial and try there slots.

  • @yadusolparterre
    @yadusolparterre Před 2 lety

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

  • @deload
    @deload Před 3 lety

    2x

  • @Martin-jq8th
    @Martin-jq8th Před 2 lety

    I'm watching on 1.6x

  • @klauslife10
    @klauslife10 Před 3 lety

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

  • @OmarAlsaheb
    @OmarAlsaheb Před 2 lety

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

  • @JeffPohlmeyer
    @JeffPohlmeyer Před 3 lety

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

  • @zacharyallen4270
    @zacharyallen4270 Před 3 lety +1

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

  • @grapes639
    @grapes639 Před 3 lety

    Thought Slots were going away with Vue3?

    • @ProgramWithErik
      @ProgramWithErik  Před 3 lety +1

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

    • @grapes639
      @grapes639 Před 3 lety +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 Před 3 lety

      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.

  • @JoeSmith-kn5wo
    @JoeSmith-kn5wo Před 3 lety

    Yes, I watch in 2x speed 😁

  • @stevenluoma1268
    @stevenluoma1268 Před 3 lety +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 Před 3 lety

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

  • @matteobagni1235
    @matteobagni1235 Před 3 lety

    I watch everything at 1.5