当我们在开发中,遇到表单提交的时候这时候又需要写一大堆的判断是否为空的时候,又需要写一大度if else 去判断当前是否为空,代码可读性太差了
提取向后端发送的数据 object 对象
利用for循环去判断当前值是否为空
对象对应的提示信息
let tempData = {
com_addr: this.gsAddress, // 是 公司地址
com_code: this.qiCodes, // string 是 公司代码
com_name: this.qiName, // string 是 公司名称
com_owner: this.frNmae, // string 是 公司法人
email: this.lxEmail, // string 是 联系人邮箱
mobile: this.lxTel, // string 是 联系人手机
owner_idcode: this.frIDCard, // string 是 法人身份证
verify_code: this.yzCodes, // string 是 短信验证码
your_name: this.lxName, // string 是 联系人姓名
}, m=0, tempTip = ['请填写公司地址', '请填写企业信用代码', '请填写公司名称', '请填写法人姓名', '请填写联系人邮箱', '请填写联系人手机', '请填写法人身份证', '请填写短信验证码', '请填写联系人姓名']
for(let i in tempData){
if(tempData[i].length <= 0){
console.log(tempTip[m])
return
}
m++
}