Using the instance properties approach in a plugin, and after registering that plugin in nuxt.config.js
, I'm unable to access those properties in asyncData
:
export default {
async asyncData({ app }) {
console.log(app.$myVar); // === undefined
return {};
}
}
Probably related, I can't access any $variables
on app
. Here is what app
consists of:
// console.log(Object.keys(app));
[ 'router',
'store',
'_nuxt',
'head',
'data',
'beforeCreate',
'created',
'mounted',
'watch',
'methods',
'components',
'render',
'staticRenderFns',
'_ssrRegister',
'__file' ]
But of course, the context docs say I should be able to.
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1521">#c1521</a>)</em></sub></div>The root vue instance that includes all your plugins. For example, when using axios, you can get access to $axios through context.app.$axios