国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

解決vue 使用axios.all()方法發(fā)起多個(gè)請(qǐng)求控制臺(tái)報(bào)錯(cuò)的問(wèn)題

瀏覽:4日期:2022-11-03 16:41:34

今天在項(xiàng)目中使用axios時(shí)發(fā)現(xiàn)axios.all() 方法可以執(zhí)行但是控制臺(tái)報(bào)錯(cuò),后來(lái)在論壇中看到是由于axios.all() 方法并沒(méi)有掛載到 axios對(duì)象上,需要我們手動(dòng)去添加

解決vue 使用axios.all()方法發(fā)起多個(gè)請(qǐng)求控制臺(tái)報(bào)錯(cuò)的問(wèn)題

== 只需要在你封裝的axios文件里加入 ==

instance.all = axios.all

就完美解決了!

補(bǔ)充知識(shí):vue項(xiàng)目中使用axios.all處理并發(fā)請(qǐng)求報(bào)_util2.default.axios.all is not a function異常

報(bào)錯(cuò):

_util2.default.axios.all is not a function

代碼:

init () { util.axios.all([this.getCourseInit(), this.getConfirmInit()]).then(util.axios.spread((indexRes, confirmRes) => { // 兩個(gè)請(qǐng)求現(xiàn)在都執(zhí)行完成 this.classData = indexRes.data.today_course.map(item => { item.time = timeUtil.formatDate2Str(item.start_time, ’HH:mm’) + ’~’ + timeUtil.formatDate2Str(item.end_time, ’HH:mm’); return item; }); this.count.count_course_today = indexRes.data.count.count_course_today; this.count.count_student_not = indexRes.data.count.count_student_not; this.count.count_student_all = indexRes.data.count.count_student_all; this.count.count_teacher_all = indexRes.data.count.count_teacher_all; this.isLoading = false;})); }, getCourseInit () { return util.axios.get(’/index’); }, getConfirmInit () { return util.axios.get(’/course-confirm’); },

原因:

axios實(shí)例沒(méi)有all這個(gè)方法,all是axios的靜態(tài)方法

解決辦法:

以下方法不是最好的,還沒(méi)找到更好的解決辦法,目前先這樣解決。

// 引入axios import axios from ’axios’; init () { axios.all([this.getCourseInit(), this.getConfirmInit()]).then(axios.spread((indexRes, confirmRes) => { // 兩個(gè)請(qǐng)求現(xiàn)在都執(zhí)行完成 this.classData = indexRes.data.today_course.map(item => { item.time = timeUtil.formatDate2Str(item.start_time, ’HH:mm’) + ’~’ + timeUtil.formatDate2Str(item.end_time, ’HH:mm’); return item; }); this.count.count_course_today = indexRes.data.count.count_course_today; this.count.count_student_not = indexRes.data.count.count_student_not; this.count.count_student_all = indexRes.data.count.count_student_all; this.count.count_teacher_all = indexRes.data.count.count_teacher_all; this.isLoading = false;})); }, getCourseInit () { return util.axios.get(’/index’); }, getConfirmInit () { return util.axios.get(’/course-confirm’); },

以上這篇解決vue 使用axios.all()方法發(fā)起多個(gè)請(qǐng)求控制臺(tái)報(bào)錯(cuò)的問(wèn)題就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: IOS
相關(guān)文章:
主站蜘蛛池模板: 欧美日韩在线观看区一二 | 一级黄片一级毛片 | 爱综合| 亚洲a在线视频 | 男女做性免费视频软件 | 日本特爽特黄特刺激大片 | 毛片免费看网站 | 久久久久久久久久久视频国内精品视频 | 色综合久久久久久888 | 亚洲男人的天堂视频 | 一区二区网站在线观看 | 日本三级s级在线播放 | 印度最猛性ⅹxxxxx | 亚洲毛片免费在线观看 | 深夜做爰性大片中文 | 亚洲精品播放 | 精品久久久久久久久中文字幕 | 欧美 在线 成 人怡红院 | 永久网站色视频在线观看免费 | 亚洲成人在线视频网站 | 国内自拍第100页 | 欧美丰满大乳大屁股毛片 | 欧美成人全部视频 | 久久精品国产亚洲7777 | 欧美手机手机在线视频一区 | 91色综合久久 | 国产精品极品美女自在线看免费一区二区 | 理论片免费午夜 | 伊人色综合久久天天人手人停 | 亚洲一区二区三区高清 | 在线观看香蕉免费啪在线观看 | 成年午夜性爽快免费视频不卡 | 欧美人拘一级毛片 | 精品热99| 一区二区三区四区视频 | 亚洲一区中文字幕在线 | 另类专区国产在线视频 | 亚洲在线播放视频 | 国产精品免费视频一区一 | 欧美一级成人免费大片 | 亚洲欧洲日韩综合色天使不卡 |