How to import Nuxt object in External JS file?
to allow me to use all project plugins
such as
this.$axios
this.$store
For further actions, you may consider blocking this person and/or reporting abuse
For further actions, you may consider blocking this person and/or reporting abuse
arjun -
sharathchandark -
Hamza Khan -
Ahmed Rakan -
Top comments (3)
You can't really do that because the Nuxt instance is not natively supported in a vanilla JS file, but you could write your function by supposing it does have the context.
For example, if you have a JS file that does some kind of logic and it needs the help of Nuxt's context, you write it like this
So, create your JS function like it does have the context, and when you're calling it in your
.vue
file, you can call it with something like thishello
i have a nuxtjs project of listing booking
I have done all my API cal and configuration on " index.js in the store folder " and would link to display the listing gotten from the API call on my "listing.vue page " please how do I call do to print my data gotten or make my index.js accessable all over the app
app setup
{
"name": "lisngbook,,
"version": "1.0.0",
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate"
},
"dependencies": {
"@nuxtjs/axios": "^5.13.6",
"core-js": "^3.9.1",
"nuxt": "^2.15.3",
},
"devDependencies": {
"@nuxtjs/moment": "^1.6.1"
},
Hey, I've answered you on Stackoverflow: stackoverflow.com/questions/749019... π