<script>
export default {
mounted() {
console.log('判断数据是否为空值' + this.isNull({ a: '测试' }));
},
methods: {
//判断数据是否为空值,为空返回true,有值为false
isNull(data) {
if (!data) return true;
if (JSON.stringify(data) === '{}') return true;
if (JSON.stringify(data) === '[]') return true;
return false;
}
}
};
</script>
最后
以上就是辛勤乌冬面最近收集整理的关于js判断数据是否为空值的方法的全部内容,更多相关js判断数据是否为空值内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复