美文网首页
axios vue AJax

axios vue AJax

作者: 丶End | 来源:发表于2018-12-18 17:09 被阅读0次
npm install axios --save // 安装


<script>
import HomeHeader from './header'
import HomeSwiper from '@/components/Swiper'
import HomeNav from './nav'
import HomeRecommend from './recommend'
import axios from 'axios'

export default{
  name: 'home',
  components: {
    HomeHeader,
    HomeSwiper,
    HomeNav,
    HomeRecommend
  },
  data(){
      return{
          city:'北京',
          swiper:[]
      }
  },
  mounted() {
      this.gethomeinfo()
  },
  methods:{
      gethomeinfo(){
          axios.get("/api/index.json").then(this.consolelog)
      },
      consolelog(data){
          var  json=data.data
            if(json.ret){
                const data=json.data;
                this.city=data.city;
                this.swiper=data.swiperSlides;
                 console.log  (data);  
            }
         
      }
  }
}
</script>









相关文章

网友评论

      本文标题:axios vue AJax

      本文链接:https://www.haomeiwen.com/subject/cqrxkqtx.html