首页 > 其他 > 详细

POST 请求,前台有参数,但是后端接受到的为null

时间:2021-06-08 17:10:53      阅读:14      评论:0      收藏:0      [点我收藏+]

问题描述:

POST 请求,前台有参数,但是后端接受到的为null

技术分享图片

 

 解决方案:

(1) let info =  new URLSearchParams()  

把参数封装到info 中  info.append()  加入参数

      const info = new URLSearchParams()
      info.append(‘uid‘, this.uid)
      info.append(‘part_id‘, this.part_id)
      info.append(‘app_type‘, 1)
      getNewExerciseList(info).then(res => {
        const data = res.result
        this.result_id = data.result_id
        this.len = data.list.length
        data.list.forEach(element => {
          if (element.type === 1 || element.type === ‘1‘) {
            element.radio = ‘‘
          } else if (element.type === 2 || element.type === ‘2‘) {
            element.checkList = []
          }
        })
}

  (2)引入QS

技术分享图片

 

 

  sbt(){
        let data = {
         ‘username‘: ‘ddd‘,
         ‘password‘: ‘101010‘
        }
         
                  this.axios({
                            method: "post",
                            url: ‘/api/PsychoSys/regedit.action‘,
                            data: Qs.stringify(data)
                        })
                        .then(function(res) {
                           console.log(res);
                       })
                        .catch(function(err) {
                           console.log(err);
                       });
 
      },

  

POST 请求,前台有参数,但是后端接受到的为null

原文:https://www.cnblogs.com/qinyuanchun/p/14862178.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!