使用Vrequest出现的问题
发布于 6 年前 作者 yong59 1436 次浏览 来自 问答

由于本人的客户是海外,所以只能使用了Vrequest做数据传输(海外PHP服务器)

https://github.com/guren-cloud/v-request

数据传输一切正常,但是最终输出的array数据非常奇怪

- 当前的表现

array (

  ‘{“title”:“666”,“email”:“666@666”,“phone”:“00000000”,“services”:“专业建房”,“suburb”:“666”,“details”:""}’ => ‘’,

)

- 预期表现

array (

  ‘nickname’ => ‘李栋’,

  ‘password’ => ‘123456’,

  ‘sex’ => ‘男’,

  ‘status’ => ‘true’,

  ‘aihao’ => ‘cy,hj,tt’,

  ‘grade’ => ‘66’,

)

POST的代码在代码片段里面

formSubmit(e) {
    console.log('form发生了submit事件,携带的数据为:', e.detail.value)
    const params = e.detail.value
    wx.vrequest({
      url: 'http://jachomeliving.com.au/miniprogram/getdata.php',
      data: {
        'title': params.title,
        'email': params.email,
        'phone': params.phone,
        'services': params.services,
        'suburb': params.suburb,
        'details': params.details
      },
      method: 'POST',
      header: {
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res.data)
      }
    })
    //校验表单
    this.showModal({
      msg: '你的留言已经发送,我们的专业客服会尽快回复您'
    })
  }

请问应该如何解决?非常感谢了!

1 回复

你提交的数据不就是title什么的吗,哪里有你想要的nickName等等

回到顶部