当前位置 : 主页 > 手机开发 > ROM >

axios请求获取五分彩系统搭建制作数据

来源:互联网 收集:自由互联 发布时间:2021-06-10
一、首先导入用到的组件和axios五分彩系统搭建制作q115.28.8.00.9.9import HomeHeader from ‘./components/Header‘import HomeSwiper from ‘./components/Swiper‘import HomeIcons from ‘./components/Icons‘import HomeRec

一、首先导入用到的组件和axios五分彩系统搭建制作q<115.28.8.00.9.9>import HomeHeader from ‘./components/Header‘import HomeSwiper from ‘./components/Swiper‘import HomeIcons from ‘./components/Icons‘import HomeRecommend from ‘./components/Recommend‘import HomeWeekend from ‘./components/Weekend‘import axios from ‘axios‘export default {name: ‘Home‘,components: {HomeHeader,HomeSwiper,HomeIcons,HomeRecommend,HomeWeekend},二、在data中将要用到的数据给一个初始值,为空data () {return {swiperList: [],iconList: [],recommendList: [],weekendList: []}},三、在methods中写方法,发送axios获取数据methods: {getHomeInfo () {axios.get(‘/api/index.json‘).then(this.getHomeInfoSucc)},getHomeInfoSucc (res) {res=res.dataif (res.ret && res.data) {const data = res.datathis.swiperList = data.swiperListthis.iconList = data.iconListthis.recommendList = data.recommendListthis.weekendList = data.weekendList}}},mounted () {this.getHomeInfo()}}四、传递数据<div><home-header></home-header><home-swiper :list="swiperList"></home-swiper><home-icons :list="iconList"></home-icons><home-recommend :list="recommendList"></home-recommend><home-weekend :list="weekendList"></home-weekend></div>五、封装 axios通过简单的配置就可以本地调试线上环境, 这里结合业务封装了axios 。

上一篇:PyTorch基础
下一篇:Prometheus 运维监控
网友评论