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

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

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

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

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

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

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

instance.all = axios.all

就完美解決了!

補充知識:vue項目中使用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實例沒有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)。

標簽: IOS
相關(guān)文章:
主站蜘蛛池模板: 久久免费精品国产72精品剧情 | 日本毛片在线 | 国产一级毛片在线 | 真正国产乱子伦高清对白 | 久草在线新视频 | 欧美高清一区二区三区欧美 | 手机福利片 | 亚洲永久 | 成人影院一区二区三区 | 日韩欧美国产成人 | 青青热久久综合网伊人 | 亚洲国产精品综合久久20 | 亚洲欧美日韩中文字幕在线 | 日韩中文字幕在线免费观看 | 免费在线看a | 久久亚洲私人国产精品va | 欧美特黄一级视频 | 免费一级夫妻a | 亚洲精品国精品久久99热 | 久久一日本道色综合久 | 97视频在线播放 | 精品国产乱码久久久久久一区二区 | 成人午夜免费在线观看 | 免费v片在线观看 | 国产成人不卡亚洲精品91 | 一品道一本香蕉视频 | 成人做爰视频www网站 | 精品国产自 | 真人毛片视频 | 另类欧美日韩 | 成人中文字幕在线观看 | 国产精品久久精品视 | 点击进入不卡毛片免费观看 | 韩国三级日本三级香港三级黄 | 国产精品爱久久久久久久9999 | 日韩欧美国产精品第一页不卡 | 免费乱码中文字幕网站 | 久久伊人男人的天堂网站 | 国产欧美日韩在线观看一区二区三区 | 特级淫片日本高清视频 | 日韩国产成人精品视频人 |