使用 axios 发送 ajax 请求

1. 在线上建立一个分支~index-ajax

 

2. 将线上分支拉到本地

 

3. 安装axios ~ 启动项目

 

import axios from 'axios'

methods:{
      getMyHeader () {
          axios.get('/api/index.json')
          .then(this.getHeaderSucc)
      },
      getHeaderSucc (res) {
          console.log(res)
      }
  },
  mounted () {
      this.getMyHeader()
  }
proxyTable: {
        '/api':{
            target: 'http://localhost:8080',
            pathRewrite:{
                '^/api': '/static/mock'
            }
        }
    }

 

posted on 2018-07-10 14:44  素~  阅读(236)  评论(0编辑  收藏  举报