COMPONENT COMMUNICATION (PROPS / EVENTS) | VueJS | Learning the Basics

Поделиться
HTML-код
  • Опубликовано: 2 ноя 2024

Комментарии • 150

  • @gknt694
    @gknt694 6 лет назад

    Two sentences give me the whole idea in 2 minutes. This man is great!

    • @academind
      @academind  6 лет назад +1

      Wow, that's so cool to read, thank you very much for sharing this awesome feedback!

  • @rubickon
    @rubickon 4 года назад

    just right now, in 2020, i needed to pass variables from store to vuetify calendar item. in a component that repeats itself many times. each time with different data comes from store.
    you solution just worked perfectly for me. thank you.

  • @chris_ea
    @chris_ea 3 года назад

    I love Vue! It took one week to break the code. By being a old fashioned PHP programmer i really saw the light!

  • @Ahmed.r.a
    @Ahmed.r.a 7 лет назад

    I had to watch this video twice and repeated parts of it because the purpose of the example was not so clear and it understood at very end of the lesson. many thanks for such amazing lessons.

    • @academind
      @academind  7 лет назад

      Happy to hear you enjoyed it, thanks for your feedback Ahmad!

  • @longinos10
    @longinos10 7 лет назад +85

    I got my brains scrambled

    • @dinfarfar1020
      @dinfarfar1020 5 лет назад +2

      Hahaha, this in my life.

    • @PB72UK
      @PB72UK 5 лет назад +3

      Once u use it a few times it's a lot easier to understand

    • @christonit6895
      @christonit6895 5 лет назад +5

      Once you repeat it like 5 times, it becomes second nature XD The tricky part is the event emition.

  • @otherchannel1199
    @otherchannel1199 7 лет назад +1

    Max - your vids are great. This topic is not articulated well in the docs and your vid cleared some things up. Really nice.

    • @academind
      @academind  7 лет назад

      Great to hear that, thanks so much !

  • @hamzanouali6051
    @hamzanouali6051 7 лет назад +2

    OMG, your way in explaining things is awesome and i really like your series

    • @academind
      @academind  7 лет назад

      Awesome to read that you like my explanations. Thank you so much Hamza :)

  • @parihar-shashwat
    @parihar-shashwat 6 лет назад +1

    You are awesome.
    The only place where I get my answer quickly. Thanks for upload (y)

    • @academind
      @academind  6 лет назад +1

      So happy to read that Shashwat, thanks a lot for your support!

  • @Texas20Young
    @Texas20Young 7 лет назад

    Thank you so much! I spent an hour trying to figure this out another way.

    • @academind
      @academind  7 лет назад

      Great to hear you liked it!

  • @israeliloba
    @israeliloba 4 года назад

    at first, I didn't understand but after practice I got the point

  • @charleswang3136
    @charleswang3136 7 лет назад

    Very good tutorial. I am new to vue.js, and this video clip tells me how to use props and events.
    Many thanks.

    • @academind
      @academind  7 лет назад

      Happy to hear that this was helpful Charls - thanks for your nice feedback!

  • @NoahNobody
    @NoahNobody 6 лет назад +1

    I feel I would need a complete series on component communication with props/events to understand them.

    • @AkshaySaini
      @AkshaySaini 6 лет назад +1

      Try using Vuex, that's what it is meant for. :)

  • @tastybrains
    @tastybrains 6 лет назад +1

    your teaching style is great

    • @academind
      @academind  6 лет назад

      Thanks a lot, really makes me happy to read that!

    • @tastybrains
      @tastybrains 6 лет назад

      I've signed up for your full course on Udemy. it's very thorough

  • @kelna2
    @kelna2 3 года назад +1

    THANK YOU SO MUCH!!!! I've been struggling with this and you cleared it up for me :)

  • @exnihilodub
    @exnihilodub 6 лет назад +13

    Hey man, thanks for the tutorials. For someone who started developing like me, they're very helpful. I think It became incredibly painful to follow after 5:29. Not because of your narrative, but because how vue.js implemented this. Is it me or is it really counter-intuitive when it comes to 2-way binding between separate components?

  • @jonmultimedia
    @jonmultimedia 2 года назад +1

    It's a 2016 video but still. Just started with Vue and component communication is still quite confusing. After hours struggling this helped me fix my issue :D Thank you!

  • @edarioq
    @edarioq 6 лет назад +2

    Hey man, you saved me with this tutorial, thanks!

    • @academind
      @academind  6 лет назад

      Awesome to read that Edgar, thank you for your great feedback!

  • @foodmania4292
    @foodmania4292 6 лет назад

    ah . its a brilliant teaching way ever i have seen :) keep it up such easy and cool examples and please make an video on VUEX with such easy examples , i really need.

    • @academind
      @academind  6 лет назад

      Thanks so much for your absolutely fantastic feedback Chalak, this really means a lot to me! I actually do have a Vuex series, maybe this is also interesting for you: academind.com/learn/vue-js/vuejs-and-vuex/

  • @ManjeetKaur-mv1oc
    @ManjeetKaur-mv1oc 5 лет назад +2

    Nice work BUDDY

  • @napoleonborntoparty5437
    @napoleonborntoparty5437 7 лет назад

    Дай тебе Бог здоровья, братишка)

  • @abdelkaderdrabo1996
    @abdelkaderdrabo1996 8 лет назад +1

    vuejs is the best of the bests

  • @1234zaptor
    @1234zaptor 5 лет назад

    I kind of confuse but fun. Thumbs-up!

  • @NilanjanSiromani88
    @NilanjanSiromani88 7 лет назад

    I love the way of teaching ! :-)

    • @academind
      @academind  7 лет назад

      And I love your comment Nilanjan, thank you for your awesome feedback!

  • @marinauliano6617
    @marinauliano6617 6 лет назад

    Thank you, this is exactly what i needed

    • @academind
      @academind  6 лет назад

      Great to hear that, thank you so much!

  • @brandon_j478
    @brandon_j478 7 лет назад

    Great video. Great channel. You are very good at articulating these concepts in a concise manner. I think it would be helpful for me if the naming of your components and their content was more semantic (i.e. Parent Comp, Child Comp, etc...). Love your work! You contributed to me getting my first developer job.

    • @academind
      @academind  7 лет назад

      Thanks for your awesome feedback and for this suggestion! :)

  • @Xelacedrom
    @Xelacedrom 3 года назад

    You rock!!! thank you so much

  • @aschopenhauer4476
    @aschopenhauer4476 7 лет назад

    I was having trouble with the last part of this tutorial. I don't know if there was a change to babel, Vue.js, or one of the other packages since this video was published. In order to make it work, I had to make a couple of changes. First, I changed the app-input tag to the following:
    Somehow the camel-case name for the event was throwing it off. Of course, I also had to change the emit statement in the changeMessage function for the input component to: this.$emit('messagechanged', this.message);
    Second, I had to add the 'updateMsg' method to the app-input component and defined it like so:
    export default {
    data() {
    .....
    },
    components: {
    ......
    },
    methods: {
    updateMsg(val) {
    this.message = val;
    }
    }

  • @jeanpaul1304
    @jeanpaul1304 7 лет назад

    Great examples!

  • @TheThreeOfLife91
    @TheThreeOfLife91 3 года назад

    Hi there, I'm using buefy autocomplete instead of input and in my case you have to change "event.target.value" to just "event"

  • @stefandudasko8984
    @stefandudasko8984 7 лет назад

    you saved my ass, dude!

    • @academind
      @academind  7 лет назад

      So awesome to read that stefan! I'll try my best to keep it going.

  • @kishandakshitha5560
    @kishandakshitha5560 6 лет назад

    Superb tutorial, I just have a problem mu props data is returning null value. Anyplace where I have gone wrong?

  • @ValisVengeance
    @ValisVengeance 7 лет назад

    Your Udemy course is ace btw!

    • @academind
      @academind  7 лет назад

      Thanks so much, that's awesome to hear - I'm glad you're enjoying it! :)

  • @musoverda5500
    @musoverda5500 7 лет назад +1

    cool example! possible variables would need to give more unique names for clarity. but in general - cool example!

    • @academind
      @academind  7 лет назад

      Thanks for your suggestion and the great feedback! I'll try to be more clear about my variable naming/ choose better names in the future ;-)

    • @musoverda5500
      @musoverda5500 7 лет назад

      I think in your example you have a good show one of the main features of Vue.js - the ability to change data. In particular, modifying data through a surfacing event.

    • @musoverda5500
      @musoverda5500 7 лет назад +1

      it seems to me, in this series of videos on Vue.js you missed one important and rather intricate ( I think ) point in Vue.js - there is the theme of the animation ( transition )?

    • @academind
      @academind  7 лет назад

      It's true, I focus on the main features here. If you want to dive deeper into Vue.js (e.g. also learn more about Animations), you may have a look at my >16hour course on Udemy - would be great to welcome you there. It's optional of course, I'll also keep on releasing content on RUclips but it will of course be more general/ cover a broader range of topics/ frameworks/ languages.

  • @bhupenderKeswani
    @bhupenderKeswani 7 лет назад +1

    Hello Sir, I need your help
    Scenario :
    I have created a parent and few child components
    and those child components have some form-elements, all i have to do is to grab data from all those form-elements, at time of submit(which is part of parent)
    Actual output
    So how can i get user data (text/select/radio) from different child components into parent component ?

  • @dannysdianrachmantyo3545
    @dannysdianrachmantyo3545 2 года назад

    Hey, can i ask? When i call the 'messageChange' in Message.vue, i got error like 'v-on is missing expression.' and '[vue/valid-v-on]
    'v-on' directives require a value or verb modifier (like 'stop' or 'prevent').'

  • @allenchun48
    @allenchun48 6 лет назад

    What if you have multiple field inputs inside input component? Do I need to add multiple methods to handle the changes in my inputs?

  • @kagisokoos1766
    @kagisokoos1766 7 лет назад

    i have different components in my Components folder, how do i register each of them with Vue.component('multiselect',multiselect) just for example.

  • @brohammer_ua
    @brohammer_ua 6 лет назад

    cool video, thank you!

    • @academind
      @academind  6 лет назад

      Thanks a lot for your comment Kirill!

  • @brawndo8726
    @brawndo8726 5 лет назад +3

    Is it necessary to set `this.message` in the child? It should propagate down from the parent after the event is handled, no?

    • @Zhuclam
      @Zhuclam 5 лет назад

      Indeed, it's not necessary

  • @gnawlej9163
    @gnawlej9163 7 лет назад

    Is there a way to access the 'msg' prop from the data() function's definition?

  • @vectorfield
    @vectorfield 7 лет назад

    Just trying to wrap my head around this way of passing props, but if the message property in the Input component constantly gets overwritten by it's parent component (_Message.vue_) then couldn't you theoretically just emit the event passing in _e.target.value_ as the second param and leave line 18 _this.message = e.target.value;_ out of the changeMessage() method entirely?
    This seems to work but I'm not sure whether or not this is bad practice.
    Just for clarity I mean changing it to look like this:
    changeMessage(e) {
    this.$emit('messageChanged', e.target.value);
    }

    • @academind
      @academind  7 лет назад +1

      Yes, you don't have to overwrite the prop, you can emit the changed value directly. I only did overwrite it to show that you also can use properties everywhere in your code and even (temporarily) overwrite them.

    • @vectorfield
      @vectorfield 7 лет назад

      Ah I see! Thanks for your amazing content and all the effort you put into your videos Max, you deserve way more views and subs imo.

  • @moswilam91
    @moswilam91 6 лет назад +1

    this is a bit confusing to me. i'd suggest supporting the theoretical explanation with a real-life example as to how and why would we need to use such a confusing concept. though you are an incredible teacher and easy to understand in general.

    • @academind
      @academind  6 лет назад +1

      Thanks for your feedback, much appreciated! :)

    • @moswilam91
      @moswilam91 6 лет назад

      you are very welcome), I actually am watching your Vue course in Udemy right now :).
      I am a Junior Front-End developer at the moment, VueJs is my first JavaScript framework. if you'd advice me regarding my next step after Vue, do you think it's better to have another framework? React for instance? or move to learn backend and server side languages?
      thanks in advance)

  • @ikhsanrahman9703
    @ikhsanrahman9703 5 лет назад

    how did you record your self and screen like that ? what tools did you use ?

    • @academind
      @academind  5 лет назад

      Please have a look at these videos Ikhsan => ruclips.net/video/RqZqmTUOaUo/видео.html

  • @markjosephpadua9257
    @markjosephpadua9257 5 лет назад

    thanks for this tutorial, it helps me a lot.

  • @spacedreamer12
    @spacedreamer12 7 лет назад

    Max,
    Is there a way to make the Udemy course modules combined into longer vids like here in your RUclips channel?
    The shorter length vids, I sometimes have to reference something you said earlier and I would have to go back to the previous video to refresh. Whereas with a longer video, I can just rewind
    Not a deal breaker though , your course is amazing regardless

    • @academind
      @academind  7 лет назад +1

      Actually, most students prefer shorter videos, that's why I'll stay with this approach. I guess the possibility to make short breaks between "learning chunks" is something people like :)

  • @ilouHD
    @ilouHD 7 лет назад

    Hey, first I want to thank you for your tutorials. You speak a good understandable englisch and you can explain in a very good way.
    However, I have a slight problem: In my Vue-Instance I'm creating in my main.js I define a filter named "translate". It should be used to replace a string (key) with a translated message (value). Now I'm trying to make this filter accessible in all my components, but I don't have any idea to do this. I think adding registering the filter in every component is bad practise. So how can I access a filter defined in my Vue-Instance in all components without placing my code for the filter in every single component I have?

    • @academind
      @academind  7 лет назад

      Thanks for your awesome feedback! If you want ta global filter, simply use Vue.filter('filterName', (value)=>{...}) in your main.js file (before you create the new Vue() instance). You can then use such a filter everywhere

  • @usefulinfo1465
    @usefulinfo1465 4 года назад

    what the difference between 2 way binding and Props Down Events Up ?

  • @sadekhossain9566
    @sadekhossain9566 7 лет назад

    how to send data from global vue instance to a vue component? I have an app.js file where i have some data which need to get sent to a vue components. how to so that?

  • @thienvu2683
    @thienvu2683 4 года назад

    Thank Sir

  • @heshramsis5038
    @heshramsis5038 6 лет назад

    thank you so much

  • @JesusMurF
    @JesusMurF 6 лет назад

    I love Vue ❤️, do you recommend me your udemy course? I just have basic knowledge of Vue

    • @academind
      @academind  6 лет назад

      I'm also a big Vue fan and I definitely recommend the course as it shows you how to work with view step-by-step. In case you're not sure you can also have a look at the first module (it's for free) to get a better feeling for the course content: www.udemy.com/vuejs-2-the-complete-guide/?couponCode=ACAD_M

  • @Nem0licious
    @Nem0licious 7 лет назад

    mutating the props directly will give error vuejs.org/v2/guide/components.html#One-Way-Data-Flow, also does vuejs.org/v2/guide/components.html#Non-Parent-Child-Communication apply to the scenarios in the video ?

    • @academind
      @academind  7 лет назад

      It gives you a warning, not an error. In many cases, you might not want to mutate props because your changes get overwritten. But sometimes you actually want that behavior and there's nothing wrong with overwriting props.

  • @punpunmuk2751
    @punpunmuk2751 6 лет назад

    Superrrrrrrrrrrrr!!!!!!!

  • @alexchiu
    @alexchiu 5 лет назад +12

    Is it just me , or this really confusing?

    • @gabrielprrd
      @gabrielprrd 5 лет назад +3

      All these big frameworks are very confusing for beginners, apparently. Everyone says it's difficult at first but is worth learning for bigger projects and, well... We have to believe them.

    • @Auzep
      @Auzep 5 лет назад +3

      It's an absolute fuckfest. What the fuck was wrong with html css and pure JS. Fuck frameworks.

    • @viktorskarlatov8227
      @viktorskarlatov8227 5 лет назад

      Guys... chill. Take your time, it's worth it. For large projects, where the meat is, such frameworks and tools are the bare minimum. It may look daunting at first but when you understand the challenges of big projects with many people collaborating you will see that even these frameworks and tools are not enough.

    • @Auzep
      @Auzep 5 лет назад +1

      @@viktorskarlatov8227 if they're not enough then they're not good tools. They're just the less "shitty" tools. Maybe a really useful framework is yet to be created. At least vanilla JS is not a complete mess to understand

    • @Zhuclam
      @Zhuclam 5 лет назад

      Vue is just a library, and it's the easiest between the most popular frameworks/libraries.
      I know the kind of stuff you see in this video seems not difficult, but like a lot to learn and even memorize, but once you write 2 or 3 components, it becomes pretty repeating and obvious, so you don't even need to get your head around it except for the first couples times.
      Also, all these tools are way faster and better than anything you could do with vanilla (except for small projects, of course).

  • @faraznisar3752
    @faraznisar3752 Год назад

    Still can't believe that I've been working with a Vue project and never come across two way binding in any place 🤣

  • @afterglow392
    @afterglow392 6 лет назад

    This totally fucked my brain up

  • @roidrage420
    @roidrage420 6 лет назад +5

    .......proof of concept that two-way data binding is a bad idea?

  • @Влад-и2л
    @Влад-и2л 6 лет назад

    Great)

  • @loremibsom
    @loremibsom 4 года назад

    how can you do this in 1 file?

  • @johncovv
    @johncovv 5 лет назад

    thanks

  • @rabinpd3175
    @rabinpd3175 6 лет назад

    What is the work of export default there?

    • @academind
      @academind  6 лет назад +1

      It's required to import the component into other files. This is what allows you to split up your code

    • @rabinpd3175
      @rabinpd3175 6 лет назад

      Academind Thanks

  • @jacksonit-plus
    @jacksonit-plus 7 лет назад

    Thanks :) Like

  • @peterinvestor
    @peterinvestor Год назад

    this was the most confusing explanation ever lol

  • @peristiloperis7789
    @peristiloperis7789 5 лет назад

    I've always thought frameworks are supposed to make things easier. But in fact they just complicate things even more. Why can't we just stick to vanila js? It's so simple to use.

  • @EricTirado
    @EricTirado 7 лет назад

    How do I get it to show up in the home page. In the App.vue file?

    • @academind
      @academind  7 лет назад

      Sorry, what do you want to show up where?

    • @EricTirado
      @EricTirado 7 лет назад

      I had skipped one of your videos. Can you number them?

  • @doublemarvellous5525
    @doublemarvellous5525 6 лет назад +4

    Wait....what?

  • @peristiloperis7789
    @peristiloperis7789 5 лет назад

    The impot and export part is so confusing.

  • @FirstLast-gk6lg
    @FirstLast-gk6lg 3 года назад

    I feel like i don't understand anything about development :(

  • @wheres_bears1378
    @wheres_bears1378 5 лет назад +1

    this has always been my downfall with frameworks like view and react :(

    • @Zhuclam
      @Zhuclam 5 лет назад

      Practice makes perfect. Use any framework with about a month and you will start to find it easy (as with any other tool/language).

  • @tube2masm
    @tube2masm 7 лет назад

    It is easier to add ".sync" to prop.

    • @academind
      @academind  7 лет назад +1

      That's not correct for Vue.js 2 (which this video is about). sync is deprecated and shouldn't be used => github.com/vuejs/vue/issues/2873

  • @SuperDenkoo
    @SuperDenkoo 4 года назад

    A bit complicated explanation, even for a junior developer, who has the knowledge of the basics. I am moving over from React onto Vue and I know how props usually work in React, which is meant to be similar in Vue, but I found the explanation bit not very useful. Thank you for your time dude.

  • @محمدلطفعلیان
    @محمدلطفعلیان 3 года назад

    Hi Master Do you have email?

  • @samyambhandari6265
    @samyambhandari6265 7 лет назад

    Little bit confusing than other videos.

  • @RayhanulSumon
    @RayhanulSumon 5 лет назад

    So complicated, 😞

  • @kanundash
    @kanundash 5 лет назад

    omg too much file

  • @cardflopper3307
    @cardflopper3307 6 лет назад

    This is not one of your good videos, couldn’t follow at all

  • @hozher
    @hozher 5 лет назад

    Such a mess

  • @Savageboi506
    @Savageboi506 7 лет назад +3

    This is an extremely poor example

    • @academind
      @academind  7 лет назад +5

      Sorry to hear this - could you be more precise to help me improve future videos? What exactly did you not like about it?

    • @Savageboi506
      @Savageboi506 7 лет назад +4

      Mindspace You have two components printing out the same thing, a msg and message data with different values, and it isn't clear what you are trying to do or what the components do. It would be better if you made the components more realistic, and have clear purposes, so they are easier to distinguish.

    • @Savageboi506
      @Savageboi506 7 лет назад

      Mindspace Sorry, I was wrong, I guess I just wasn't paying attention lol.
      But why can't you change the prop? Is the reason it rerenders because it sees the prop was changed, so it renders the parent component with that sends the prop?

    • @academind
      @academind  7 лет назад +2

      You can change the prop but it gets overwritten whenever the parent component decides to pass the prop again (which happens if the data, bound to the prop in the parent component, gets updated).

    • @Savageboi506
      @Savageboi506 7 лет назад

      That's what I was thinking. Awesome.
      I'm thinking of buying your course, but I'm not sure if I would need it since I am only creating somewhat simple applications. Do you recommend it if I'm going to use Vue in production, or are these free tutorial suffice?

  • @vd853
    @vd853 5 лет назад

    If this was Angular, I would just have my components referencing from one service. No need for these emitting and listening stuff.

    • @Zhuclam
      @Zhuclam 5 лет назад

      These implementation is ripped off angular, so it's the same. Of course it's easier with services, but both vue and react also have many other ways to communicate between components. This is just the most straightforward one.

  • @jamesramputh8711
    @jamesramputh8711 6 лет назад

    This video is so confusing. like what????

    • @academind
      @academind  6 лет назад

      I'm sorry to hear that James. Can you let me know what exactly was unclear?

  • @ahmedanalattack
    @ahmedanalattack 7 лет назад

    I've got a problem:
    I am using it on a top position in my main.js file. I can use this instance to store my application state and it's works fine on dev server. But webpack doesn't allow me to build production package :(
    export const busVue = new Vue({
    data(){
    return{
    state:{}
    }
    }
    });
    any ideas how to fix?
    Thanks