欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

axios中GET和POST请求传参方式

程序员文章站 2022-04-15 13:35:17
...

1.get请求只需拼接在接口后边即可

   _that.$http.get('/syncResourceService/getSyncConfig?serviceIndexCode='+this.serviceIndexCode).then(function(res) {
      if (res && res.data && res.data.code == 0) {
           let data = res.data.data;
           _that.supportList = data.supportList;
           _that.typeCodes = data.configList;
       } else {
           _that.$message.error(res.data.msg);
       }
   }, function() {});

2.post请求及需要对象方式传参

params = {
   typeCodes:_that.typeCodes,
    serviceIndexCode:_that.serviceIndexCode
};
_that.$http.post('/syncResourceService/updateSyncConfig',params).then(function(res) {
    if (res && res.data && res.data.code == 0) {
        _that.$message({
            message: '自动同步设置修改成功',
            type: 'success'
        });
        _that.dialogVisible = false;
    } else {
        _that.$message.error(res.data.msg);
    }
}, function() {});