当前位置:网站首页>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
},
边栏推荐
猜你喜欢
Basic composition of radar
C#学习一:值类型与引用类型
架构实战营模块五作业
Review of digital image processing
墨天轮“高可用架构”干货文档分享(含Oracle、MySQL、PG资料124篇)
MCS: multivariate random variable - discrete random variable
动作捕捉系统用于苹果采摘机器人
数字图像处理复习
MCS: discrete random variables - geometric distribution
I am 35 years old. Can I change my career to be a programmer?
随机推荐
欧标插头EN50075测试项目
Development and application of NFT chain Games: Six noteworthy NFT trends in 2022
Scroll, do you understand?
What is the time complexity of the redis command?? (the actual question is about the underlying structure of redis)
Google 软件版本经历周期
LeetCode笔记:Biweekly Contest 81
MCS: multivariate random variable - discrete random variable
BFD原理与配置
LeetCode笔记:Weekly Contest 299
el-table-column行按钮防重控制loading
Informatics Olympiad all in one 2061: trapezoidal area
MySQL scheduled full database backup & rolling deletion of backup data before the specified date
12.UDP协议-bite
极化SAR地表分类
微信公共号开发,发送消息回复文本
C#学习一:值类型与引用类型
MySQL定时整库备份&滚动删除指定日期前的备份数据
深入理解 Promise 之手把手教你写一版
适用于遥感图像处理的神经网络
Review of digital image processing