Puedo importar y usar axios en un componente:
import axios from 'axios' export default function usePostLogin() { const login = async (url , data , callback) => { axios.post(url, data) // etcQuiero importar axios globalmente.
En principal.js:
import axios from 'axios' const app = createApp(App) app.component('FontAwesome', FontAwesomeIcon) app.use(createPinia()).use(router).use(axios) app.mount('#app') Pero luego aparece un error: error 'axios' is not defined no-undef
No puede agregar axios con use en Vue3, en main.js agréguelo a la propiedad global:
app.config.globalProperties.axios = axiosy en componente usarlo como:
this.axios