I like to know if there is a way to access in a plugin the context variables? Which other variables / objects exists apart from the "process" object? Unfortunately I could not found a clear description nor a reference about the "process" object at the nuxt side
i.e. plugins/helper.js
const myHelper = {
helpFunction(arg) {
if (process.server) {
...
}
return ...;
},
If you export a function in your plugin, you will automatically have access to nuxt context as it's first argument (docs):
export default (context, inject) => {
context.app.helpFunction= (arg) => {
if (process.server) {
...
}
return ...;
}
}
now you can use your helper function in any component like this:
this.$helpFunction(someArgs)...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With