zoukankan      html  css  js  c++  java
  • axios post传参后台无法接收问题

    起因是在angular项目中使用axios发送post请求,向后台传参后台一直无法接收,网上查了有说是请求头设置不对,需要把Content-Type:application/x-www-form-urlencoded;charset=UTF-8

    改了之后发现还是不行,后来终于找到原因,axios请求中params和data,不一样,post需要把参数放在data中,get请求放在params中才行

    //POST请求
    sendIndentifyCodeServer(opt){ axios.post(`${environment.path}
    /IdentifyingCode/getVcode`,opt.data).then((response)=>{ if(opt.onSuccess){ opt.onSuccess(response); } }).catch(error=>{ if(opt.onFailed){ opt.onFailed(error); } }); }


    //GET请求
    sendIndentifyCodeServer(opt){ axios.get(`${environment.path}/IdentifyingCode/getVcode`,{params:opt.data}).then((response)=>{ if(opt.onSuccess){ opt.onSuccess(response); } }).catch(error=>{ if(opt.onFailed){ opt.onFailed(error); } }); }
  • 相关阅读:
    k8s nod rc service 使用
    Linux $() 与 ${}
    Linux set
    Linux 上传下载 rz 与sz
    Linux !的使用
    K8s创建pod yaml文件详解
    Kubernetes 安装
    Python 生成器
    k8s 使用详解
    微信 网页授权
  • 原文地址:https://www.cnblogs.com/leiting/p/8475552.html
Copyright © 2011-2022 走看看