How to share data between components in VueJS

前端 未结 3 1896
庸人自扰
庸人自扰 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:13

    Use this small plugin if you have a lot of nested components:

    Vue.use(VueGlobalVariable, {
      globals: {
        user: new User('user1'),
        obj:{},
        config:Config,
        ....
      },
    });
    

    Now you can use $user in any component without using props or other

提交回复
热议问题