使用axios

import Axios from 'axios'
import VueAxios from 'vue-axios'
import AV from 'leancloud-storage'
Vue.use(AV);
Vue.use({ Axios, VueAxios});

提示not defined

main.js?3479:13 Uncaught ReferenceError: axios is not defined
at eval (main.js?3479:13)
at Object.<anonymous> (build.js:1070)
at __webpack_require__ (build.js:679)
at fn (build.js:89)
at Object.<anonymous> (build.js:919)
at __webpack_require__ (build.js:679)
at build.js:725
at build.js:728

解决方法:将Vue.use()换成Vue.prototype

Vue.prototype.$axios = axios

然后通过$axios引用,例如:

$axios.get()
Logo

前往低代码交流专区

更多推荐