当前位置:网站首页>小程序判断数据为不为空
小程序判断数据为不为空
2022-06-29 15:27:00 【坐等夕阳落time】
说明
主要就是单纯地用if(x),如果x=0,也会是false, 判断为空,所以还要再加一层判断是否为0,为0是不为空。
判断为不为0 js里不能用 == 和 != ,要用 === 和 !==
一 非对象数据的判断
// 非对象模式的判断数据为不为空
export const isDataNotEmpty = function(checkObj) {
console.log(JSON.stringify(checkObj))
let result = false
if (checkObj === 0) {
return true
}
// Checke if it is ""、 undefined、 null 、NaN、 []
if (checkObj) {
return true
}
return false
}
二 对象数据的判断
// 校验表单
verify() {
let isCorrect = true
let obj = this.dataForm
let dataFormTitle = {
spuName: '商品名称',
price: '价格',
barCode: '商品条码',
secondaryArea: '发货地区',
spuLabel: '商品标签',
saleType: '出货类型',
deliveryType: '交付类型',
payType: '付款方式',
storageStatus: '状态',
imagePath: '商品图片'
}
for (var key in obj) {
if (key !== 'barCode' && key !== 'imagePath') {
// 这种会把值为0也判断为空,所以要再判断为不为0
if (!obj[key]) {
if(obj[key] !== 0) {
if(dataFormTitle[key]){
isCorrect = false
uni.showToast({
title: dataFormTitle[key] + '为空',
icon: 'none'
})
return isCorrect
}
}
}
}
}
return isCorrect
},边栏推荐
- 雷达天线简介
- PostgreSQL source code learning (25) -- transaction log ⑥ - wait for log writing to complete
- SSL V**技术原理
- 11. application layer data transmission format / port number -bite
- GWD:基于高斯Wasserstein距离的旋转目标检测 | ICML 2021
- 遥感典型任务分析
- MCS: discrete random variable Poisson distribution
- For example, the visual appeal of the live broadcast of NBA Finals can be seen like this?
- 欧标插头EN50075测试项目
- Lumiprobe reactive dye - amino dye: cyanine 5 amine
猜你喜欢

For example, the visual appeal of the live broadcast of NBA Finals can be seen like this?

Google 软件版本经历周期

stlink故障修复

MySQL JSON array operation JSON_ array_ append、json_ array_ insert

在shop工程中,实现一个菜单(增删改查)

Basic composition of radar

Informatics Olympiad all in one 2061: trapezoidal area

MCS: multivariate random variable - discrete random variable

Review of digital image processing

雷达基本组成
随机推荐
雷达发射机
Development and application of NFT chain Games: Six noteworthy NFT trends in 2022
无意发现的【TiDB缓存表】,竟能解决读写热点问题
「游戏引擎 浅入浅出」98. SubstancePainter插件开发
MCS: multivariate random variable polynomial distribution
Lumiprobe click chemistry - non fluorescent azide: azide-peg3-oh
在shop工程中,实现一个菜单(增删改查)
Taro2.* 小程序配置分享微信朋友圈
Is it reliable to invest in REITs funds? Is REITs funds safe
近期工作总结
Why MySQL chooses b+ tree to store indexes
Lumiprobe deoxyribonucleic acid phosphate CpG 1000 solid carrier
EasyGBS调用获取实时快照接口时,出现白色方块该如何解决?
绑定证券账户到同花顺安全吗?哪家券商开户后可以绑定同花顺
Imgutil image processing tool class, text extraction, image watermarking
Implementing redis distributed locks using custom annotations
Lumiprobe reactive dye miscellaneous dye: BDP FL ceramide
Andorid Jetpack Hilt
14.IP协议-bite
PostgreSQL source code learning (24) -- transaction log ⑤ - log writing to wal buffer