axios ajax请求插件

导入axios.js

get请求

axios.get(url?key=value&key1=value1)
.then(function(data){
...
},function(err){
...
})

axios.get("url", {
        params: {  //要传的参
            id: id
        }
    })
    .then(function(data) {
        ...
    }, function(err) {
        console.log("错误")
    })


post请求
axios.post(url,{key:value,key1:value1})
.then(function(data){
...
},function(err){
...
})

posted @ 2021-03-24 16:51  终末s  阅读(60)  评论(0)    收藏  举报