• axios.request(config)
  • axios.get(url[, config])
  • axios.delete(url[, config])
  • axios.head(url[, config])
  • axios.post(url[, data[, config]])
  • axios.put(url[, data[, config]])
  • axios.patch(url[, data[, config]])

发送 GET 请求(默认的方法)

axios({
        url:'http://localhost/axios/api.php?a=1111&b=2222',
        method:'get',
        params:{
            name:'username',
        }
    }).then(res=>{
        console.log(res);
    });

发送 POST 请求

axios({
        method:'post',
        url:'http://localhost/axios/api.php',
        headers: {
            'content-type': 'application/x-www-form-urlencoded'
        },
        data:{
            name:'username',
            age:'30',
            sex:'aaa'
        }
    }).then(res=>{
        console.log(res);
    });

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注