微信小程序js代码,我的登录界面只能运行一个姓名不能为空,其他的代码不生效,请问各位大佬这是为什么?
我的微信小程序代码输入进去之后没有输入姓名框,只有姓名框提示请输入姓名不能为空,其余的系别班级等不能正常显示,请问我都代码哪里出问题了? 这是wxml代码 <view class='asd'>
<view class='title'>同学你好 </view>
<view class="a"> 姓名</view>
<input name="xingming" placeholder="请输入姓名" type="text" />
<view class='a'> 系别 </view>
<input name="xibie" placeholder="请输入" type="text" />
<view class='a'> 班级</view>
<input name="banji" placeholder="请输入" type="number" />
<view class="a"> 学号</view>
<input name="xuehao" placeholder="请输入" type="number" />
<view class="a"> 年龄</view>
<input name="nianling" placeholder="请输入" type="number" />
<view class="c"> 请各位同学填写后及时提交</view>
<button formType="submit">提交</button>
<button fromType="formReset">重置</button>
</view>
这是js代码 const app = getApp()
Page({
data: {
},
formSubmit: function (e) {
//console.log(e.detail.value);
if (e.detail.value.xingming.length == 0 || e.detail.value.xingming.length >= 8) {
wx.showToast({
title: '姓名不能为空或过长!',
icon: 'loading',
duration: 1500
})
setTimeout(function () {
wx.hideToast()
}, 2000)
}
else if (e.xibie.value.xibie.length == 0) {
wx.showToast({
title: '系别不能为空!',
icon: 'loading',
duration: 1500
})
setTimeout(function () {
wx.hideToast()
}, 2000)
}
else if (e.banji.value.banji.length == 0) {
wx.showToast({
title: '班级不能为空!',
icon: 'loading',
duration: 1500
})
setTimeout(function () {
wx.hideToast()
}, 2000)
}
else if (e.xuehao.value.xuehao.length == 0) {
wx.showToast({
title: '学号不能为空!',
icon: 'loading',
duration: 1500
})
setTimeout(function () {
wx.hideToast()
}, 2000)
}
else if (e.nianling.value.nianling.length == 0) {
wx.showToast({
title: '年龄不能为空!',
icon: 'loading',
duration: 1500
})
setTimeout(function () {
wx.hideToast()
}, 2000)
} else {
wx.request({
url: '接口路径',
header: {
"Content-Type": "application/x-www-form-urlencoded"
},
method: "POST",
data: { xingming: e.detail.value.xingming,
xibie: e.detail.value.xibie,
banji: e.detail.value.banji,
xuehao: e.detail.value.xuehao,
nianling: e.detail.value.nianling
},
success: function (res) {
console.log(res.data);
if (res.data.status == 0) {
wx.showToast({
title: '提交失败!!!',
icon: 'loading',
duration: 1500
})
} else {
wx.showToast({
title: '提交成功!!!',//这里打印出登录成功
icon: 'success',
duration: 1000
})
}
}
})
}
},
})