2
I have the following structure in my project
1. App.vue (Arquivo principal)
2. App.vue (outro arquivo que fica dentro da pasta paginas)
3. Dashboard.vue (filho do 2 app.vue)
Within my second app.See I call you component Menu
, the question is, how would I pass the data to the component Menu
?
NOTE: It is a Dashboard, and when logging in, I have the user data, I want to put in the Menu
index.js
export default new Router({
mode: 'history',
routes: [
{
path: '/',
name: 'Login',
component: Login
},
{
path: '/dashboard',
name: 'Dashboard',
children: [
{
name: 'DashboardA',
path: '/',
component: Dashboard,
meta: { requiresAuth: true }
},
{
path: '/cardapio',
name: 'Cardapio',
component: Itens
},
{
path: '/categorias',
name: 'Categorias',
component: Categorias
},
{
path: '/categorias',
name: 'Categorias',
component: Categorias
},
{
path: '/subcategorias',
name: 'SubCategorias',
component: SubCategorias
},
{
path: '/clientes',
name: 'Clientes',
component: Clientes
}
],
component: AppDashboard
}
]
})
I know that if I call the component on the page, I can pass data via props
, but in that case, I’m going to the Dashboard
, but the menu is on App.vue
, as you would do?
Do you have any part of the application managing global state? Vuex? Otherwise you will have to create a mechanism for this. I cannot answer in detail now, but see https://vuejs.org/v2/guide/state-management.html
– bfavaretto
No, I don’t use
vuex
– Rafael Augusto
A good alternative in this case may be using Event bus: https://alligator.io/vuejs/global-event-bus/
– Lucas Augusto