Javascript 我的Vuejs应用程序无法使用axios发送http post
在我的Vuejs应用程序中,我试图向我的服务器发送HTTP post,我在控制台中不断收到此错误Javascript 我的Vuejs应用程序无法使用axios发送http post,javascript,vue.js,post,axios,Javascript,Vue.js,Post,Axios,在我的Vuejs应用程序中,我试图向我的服务器发送HTTP post,我在控制台中不断收到此错误 TypeError: _api__WEBPACK_IMPORTED_MODULE_0__.default.post is not a function at Object.coursePix (services.js?87e7:5) at VueComponent._callee$ (testCourse.vue?8c89:98) at tryCatch (runtime.j
TypeError: _api__WEBPACK_IMPORTED_MODULE_0__.default.post is not a function
at Object.coursePix (services.js?87e7:5)
at VueComponent._callee$ (testCourse.vue?8c89:98)
at tryCatch (runtime.js?96cf:45)
at Generator.invoke [as _invoke] (runtime.js?96cf:271)
at Generator.prototype.(anonymous function) [as next] (webpack-internal:///./node_modules/regenerator-runtime/runtime.js:97:21)
at asyncGeneratorStep (asyncToGenerator.js?3b8d:5)
at _next (asyncToGenerator.js?3b8d:27)
at eval (asyncToGenerator.js?3b8d:34)
at new Promise (<anonymous>)
at new F (_export.js?63b6:36)
这是services.js
import api from '@/api'
export default {
coursePix (credentials) {
return api.post('coursePix', credentials)
}
}
和upload.vue
async AddCourse(){
const formData = new FormData()
formData.append('file', formData)
var obj = {
send: 'send'
}
try{
await services.coursePix(obj)
}
catch(err){
console.log(err)
}
}
我尽我所能尝试了一切,但都不起作用,我如何解决这个问题,或者我做错了什么似乎您没有检索ajax实例:
return api.post('coursePix', credentials)
return api().post('coursePix', credentials)
而不是:
return api().post('coursePix', credentials)