How to share data between components in VueJS

前端 未结 3 1818
庸人自扰
庸人自扰 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 17:57

    You can either use props or an event bus, where you'll be able to emit an event from a component and listen on another

    vm.$on('test', function (msg) {
      console.log(msg)
    })
    
    vm.$emit('test', 'hi')
    // -> "hi"
    

提交回复
热议问题