This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const actions = { | |
async nuxtServerInit ({ commit }, { $http, error }) { | |
try { | |
const menu = await $http.$gest('api/menus') | |
commit('setMenu', menu) | |
} catch (err) { | |
return error(err) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="container"> | |
<div class="menu"> | |
<nuxt-link | |
v-for="({link, label}, key) in menu" | |
:key="key" | |
:to="link"> {{ label }} </nuxt-link> | |
</div> | |
<nuxt | |
:keep-alive-props="{ max: 10 }" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const actions = { | |
async nuxtServerInit ({ commit }, { $http }) { | |
const menu = await $http.$get('api/menu') | |
commit('setMenu', menu) | |
} | |
} | |
export const state = () => ({ | |
menu: [] | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const state = () => ({ | |
menu: [] | |
}) | |
export const mutations = { | |
setMenu(state, payload) { | |
state.menu = payload | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
... | |
/** | |
* Nuxt server middlewares | |
*/ | |
serverMiddleware: [ | |
{ path: '/api/menu', handler: '~/api/menu.js' }, | |
], | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
... | |
/** | |
* Nuxt server middlewares | |
*/ | |
serverMiddleware: [ | |
{ path: '/api/menu', handler: '~/api/menu.js' }, | |
], | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
... | |
/** | |
* Nuxt server middlewares | |
*/ | |
serverMiddleware: [ | |
{ path: '/api/menu', handler: '~/api/menu.js' }, | |
], | |
... | |
} |
NewerOlder