午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

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

解決vue 使用axios.all()方法發(fā)起多個請求控制臺報錯的問題

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

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

解決vue 使用axios.all()方法發(fā)起多個請求控制臺報錯的問題

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

instance.all = axios.all

就完美解決了!

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

報錯:

_util2.default.axios.all is not a function

代碼:

init () { util.axios.all([this.getCourseInit(), this.getConfirmInit()]).then(util.axios.spread((indexRes, confirmRes) => { // 兩個請求現(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í)例沒有all這個方法,all是axios的靜態(tài)方法

解決辦法:

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

// 引入axios import axios from ’axios’; init () { axios.all([this.getCourseInit(), this.getConfirmInit()]).then(axios.spread((indexRes, confirmRes) => { // 兩個請求現(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ā)起多個請求控制臺報錯的問題就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: IOS
相關(guān)文章:
主站蜘蛛池模板: 久久久天天 | 中文字幕亚洲精品在线观看 | 国产乱淫av免费 | 婷婷伊人网 | 三级在线免费观看 | 天天综合精品 | 国产九九精品视频 | 国产成人精品av久久 | 黄色在线观看免费 | 久久亚洲在线 | 久久六六 | 青青草超碰在线 | 久久网免费视频 | 亚洲一区二区三区蜜桃 | www久久久久久久 | 欧美午夜精品 | 欧美做爰视频 | 成人亚洲欧美 | 久久不卡影院 | 国产精品成人国产乱一区 | 精品永久| 天天干视频在线观看 | 色综合国产 | 国产50页| 91视频免费在线看 | av第一页| 日日色综合 | 特黄视频| 日韩午夜高清 | 亚洲精品中字 | 精品一区二区三区在线观看视频 | 在线黄网站 | 性xxxx视频播放免费 | 日本理伦片午夜理伦片 | 一区二区国产在线观看 | 噜噜色av | 亚洲精品久久久久久久久久久久久 | 亚洲精品成 | 黄视频在线播放 | 日本高清不卡一区 | 亚洲激情欧美激情 |