当前位置:网站首页>Applet judges that the data is not empty
Applet judges that the data is not empty
2022-06-29 15:47:00 【Sit and wait for the sunset time】
explain
The main thing is to simply use if(x), If x=0, It will be false, The judgment is empty , So we need to add another layer to judge whether it is 0, by 0 Is not empty .
Judge as not 0 js You can't use == and != , Use === and !==
One Judgment of non object data
// The judgment data of non object mode is not empty
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
}
Two Judgment of object data
// Checklists
verify() {
let isCorrect = true
let obj = this.dataForm
let dataFormTitle = {
spuName: ' Name of commodity ',
price: ' Price ',
barCode: ' Bar code of goods ',
secondaryArea: ' Delivery area ',
spuLabel: ' Product label ',
saleType: ' Shipment type ',
deliveryType: ' Delivery type ',
payType: ' payment method ',
storageStatus: ' state ',
imagePath: ' Commodity images '
}
for (var key in obj) {
if (key !== 'barCode' && key !== 'imagePath') {
// This will set the value to 0 Also judged to be empty , Therefore, it is necessary to judge again as not 0
if (!obj[key]) {
if(obj[key] !== 0) {
if(dataFormTitle[key]){
isCorrect = false
uni.showToast({
title: dataFormTitle[key] + ' It's empty ',
icon: 'none'
})
return isCorrect
}
}
}
}
}
return isCorrect
},边栏推荐
猜你喜欢

Informatics Olympiad all in one 2061: trapezoidal area

14.ip protocol -bite

89.(cesium篇)cesium聚合图(自定义图片)

MCS: multivariate random variable polynomial distribution

GWD:基于高斯Wasserstein距离的旋转目标检测 | ICML 2021

I am 35 years old. Can I change my career to be a programmer?

Google software version experience cycle
![中序和后序遍历构建二叉树[递归划分区间与回溯拼接子树+中后序和中前序的相似与不同]](/img/c6/a2780620fef8bc5f7b564ef173f589.png)
中序和后序遍历构建二叉树[递归划分区间与回溯拼接子树+中后序和中前序的相似与不同]

Detailed explanation of list set

stlink故障修复
随机推荐
MCS: multivariate random variable - discrete random variable
89.(cesium篇)cesium聚合图(自定义图片)
MySQL JSON array operation JSON_ array_ append、json_ array_ insert
el-table-column行按钮防重控制loading
. Net program configuration file operation (INI, CFG, config)
C#学习一:值类型与引用类型
13.TCP-bite
Paging SQL (rownum, row_number, deny_rank, rank)
Stlink troubleshooting
NFT链游开发应用:2022年值得关注的6大NFT趋势
JS will have variable promotion and function promotion
动态监听DOM元素高度变化
postgresql源码学习(24)—— 事务日志⑤-日志写入WAL Buffer
CKS CKA ckad change terminal to remote desktop
上次给我们发福利的 TDesign ,今天讲讲它的开源故事
Why MySQL chooses b+ tree to store indexes
MCS: discrete random variables - geometric distribution
89. (cesium article) cesium aggregation diagram (custom picture)
华为云AOM 2.0版本发布
Mingdeyang xilinx-k7-325t/410t core board data manual