# 发起一个POST求

export default {
  data(){
    return { }
  },

  onLoad(){
         //案例
    this.$api.post(global.apiUrls.postWorkLike, {
      // 传入参数
    }).then(res => {
      // 接口请求成功做些什么
    }).catch(err => {
      // 接口请求失败做些什么
    })
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

# 如何在发起请求时候改变请求头

export default {
  data(){
    return { }
  },

  onLoad(){
    this.$api.post(global.apiUrls.postWorkLike, {
      // 传入参数
    }, {
      header: {
        'Content-Type': 'application/json'
      }
    }).then(res => {
      // 接口请求成功做些什么
    }).catch(err => {
      // 接口请求失败做些什么
    })
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19