When starting a new project, I used the command:
vue create hello-world
This generated essential files like HelloWorld.vue
, app.vue
, and main.js
.
Next, I followed the documentation on Npm vue-axios to install Axios:
npm install --save axios vue-axios
In the main.js
file, I imported Axios as follows:
import Vue from 'vue'
import axios from 'axios'
import VueAxios from 'vue-axios'
However, when trying to use VueAxios
according to its documentation:
const app = Vue.createApp(...)
app.use(VueAxios, axios)
I encountered a problem due to the difference in creating an app
instance in Vue 3:
createApp(App).mount('#app')
So now I'm wondering how to correctly import axios. Any suggestions?