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


问题描述:

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);
                       });
 
      },

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM