How to share data between components in VueJS

前端 未结 3 1820
庸人自扰
庸人自扰 2021-01-31 17:24

I have a fairly simple VueJS app, 3 components (Login, SelectSomething, DoStuff)

Login component is just a form for user and pass input while the second component needs

3条回答
  •  不思量自难忘°
    2021-01-31 18:00

    In Vue.js components can communicate with each other using props or events. It all depends on the relation between your components.

    Let's take this small example:

    
    

    To send information from the parent to Child, you will need to use props:

    
    
    
    

    To send information from the child to the parent, you will need to use events:

    Child Component

    
    

    Parent Component

    
    
    
    

    Check the documentation of vue.js for more information about this subject. This is a very brief introduction.

提交回复
热议问题