-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I access a method in a different page in Nuxt #3221
Comments
Normally I would create a util.js file in /assets/js, it will look like:
then import it in any vue file that need these functions, like:
if you don't want to import it manually in every vue file, then use a global mixin, https://vuejs.org/v2/guide/mixins.html#Global-Mixin, like this:
3, add main.js in nuxt.config.js:
|
Thanks!! @HoraceKeung very helpful |
Recently I did the same thing. I created a lib folder and placed all common type of function is separate file based of category (common.js, loginHelper.js etc) and just imported in a component or in mixins and then called it as you said. However, I am not sure, if we can do this then my mixins come into existence. in mixing I found a strange issue but not in lib file.. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Am trying to implement an update function for my app using axios, now how can I access this function from all my pages in the app?
The text was updated successfully, but these errors were encountered: