一、首先导入用到的组件和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 。