getInfo(){ var that = this let obj = { banner: axios.get(that.url + 'home.php?Action=banner&setaction=banner'), logo: axios.get(that.url + 'home.php?Action=advertising&setaction=logo'), code: axios.get(that.url + 'home.php?Action=advertising&setaction=code'), himg: axios.get(that.url + 'home.php?Action=advertising&setaction=himg'), link: axios.get(that.url + 'home.php?Action=infolist&QType=link'), qq: axios.get(that.url + 'home.php?Action=infocontent&setaction=qq'), mail: axios.get(that.url + 'home.php?Action=infocontent&setaction=mail'), phone: axios.get(that.url + 'home.php?Action=infocontent&setaction=phone'), Hotline: axios.get(that.url + 'home.php?Action=infocontent&setaction=Hotline') } return obj }var that = this axios.all([that.getInfo().banner, that.getInfo().logo, that.getInfo().code, that.getInfo().himg, that.getInfo().link, that.getInfo().qq, that.getInfo().mail, that.getInfo().phone, that.getInfo().Hotline ]) .then(axios.spread(function(banner,logo,code,himg,link,qq,mail,phone,Hotline){ that.banner = banner.data var swiper1 = new Swiper('.banners', { pagination: { el: '.swiper-pagination', }, autoplay: true, speed: 800, observer:true, }); that.logo = logo.data.photo that.code = code.data.photo that.htxtimg = himg.data.photo that.link = link.data that.qq = qq.data.Content console.log(qq); that.mail = mail.data.Content that.phone = phone.data.Content that.Hotline = Hotline.data.Content }))如图,axios.all()里面有多少个,就会请求少次,不是同时一齐只发一次...各路大神有没什么解决方案,或是拆开一个一个发?
添加回答
举报
0/150
提交
取消