Vue sends asynchronous request

One: post request
getXXX() {
(1)//arr is a string array
let param = JSON.stringify(arr);

(2)//定义对象
let param = {
    id: item.id,
    userName: item.userName,
    ...
  }

let url = "xxxx"
axios({
  method: "POST",
  url: url,
  data: param,
  headers: {
    "Content-Type": "application/json"
  }
}).then(res => {
})
 },

二:get请求
getXXX() {
let url = "XXX/XXX/XXX?a=" + this.a;
axios({
method: "GET",
url: url,
}).then(res => {
if (res.status == 200 && res.data.result) {

    }
  }).catch(err => {
    console.error(err);
  });
},

Guess you like

Origin blog.51cto.com/14666686/2561952