微信小程序求助

新手上路,请多包涵

问题描述

两次密码输入正确后,注册显示错误

问题出现的环境背景及自己尝试过哪些方法

相关代码

Page({
data: {},

formSubmit: function (e){
  if(e.detail.value.password == e.detail.value.re_password){
    wx.request({
      url: xxx/regist',
      data: {
        'username': e.detail.value.username,
        'password': e.detail.value.password,
      },
      method: 'POST',
      header: {
        'content-type':'application/x-www-form-urlencoded'
      },
      success: function (res){
        console.log(res.data)
        if(res.data.status == 1){
          wx.setStorage({
            key: 'username',
            data: 'JSON.parse(res.data.data).username',
          })
          wx.showToast({
            title: res.data.message + ",请返回登录",
            icon: 'success',
            duration: 2000
          })
        } else {
          wx.showToast({
            title: res.data.message,
            icon: 'loading',
            duration: 2000
          })
        }
      }
    })
  } else {
    wx.showToast({
      title: "两次输入的密码不一致,请重新输入",
      icon: 'loading',
      duration: 2000
    })
 }

},
})

你期待的结果是什么?实际看到的错误信息又是什么?

console显示的错误信息
showToast:fail parameter error: parameter.title should be String instead of Undefined;
console.error @ VM3533:1
Y @ WAService.js:6
z @ WAService.js:6
vs @ WAService.js:10
(anonymous) @ WAService.js:6
(anonymous) @ WAService.js:7
(anonymous) @ WAService.js:14
(anonymous) @ WAService.js:6
success @ regist.js? [sm]:28
function.a.(anonymous function) @ WAService.js:7
(anonymous) @ WAService.js:4
(anonymous) @ WAService.js:7
L.emit @ WAService.js:8
(anonymous) @ WAService.js:12
(anonymous) @ WAService.js:6
a @ appservice?t=1535532018517:1043
(anonymous) @ appservice?t=1535532018517:1043
b.emit @ appservice?t=1535532018517:1043
callback @ appservice?t=1535532018517:1043
setTimeout @ appservice?t=1535532018517:1043
(anonymous) @ WAService.js:4
(anonymous) @ WAService.js:4
setTimeout (async)
setTimeout @ WAService.js:4
n @ appservice?t=1535532018517:1043
c @ appservice?t=1535532018517:1043
v.onreadystatechange @ appservice?t=1535532018517:1043
XMLHttpRequest.send (async)
q @ appservice?t=1535532018517:1043
createRequestTask @ appservice?t=1535532018517:1043
invoke @ appservice?t=1535532018517:1043
invoke @ WAService.js:4
U @ WAService.js:6
H @ WAService.js:6
Rt @ WAService.js:7
e @ WAService.js:12
(anonymous) @ WAService.js:13
(anonymous) @ WAService.js:6
(anonymous) @ WAService.js:7
(anonymous) @ WAService.js:14
(anonymous) @ WAService.js:6
formSubmit @ regist.js? [sm]:5
(anonymous) @ WAService.js:19
l @ WAService.js:18
Dt @ WAService.js:19
ln @ WAService.js:20
(anonymous) @ WAService.js:20
(anonymous) @ WAService.js:19
(anonymous) @ WAService.js:10
n @ WAService.js:6
a @ appservice?t=1535532018517:1043
e.registerCallback @ appservice?t=1535532018517:1043
n.forEach @ appservice?t=1535532018517:1043
d @ appservice?t=1535532018517:1043
k.onmessage @ appservice?t=1535532018517:1043

阅读 4k
1 个回答

wx.showToast 方法的title 参数需要的是字符串,检查一下你拼接的结果是不是字符串

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题