ES6条件if语句,用于检查数组是否为空 [英] ES6 conditional if statement to check if arrays are empty
本文介绍了ES6条件if语句,用于检查数组是否为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我似乎无法让jsx es6的if语句起作用.我在做什么错了?
I can't seem to get my jsx es6 react if statement to work.. What am I doing wrong?
const otherVariables = doesntMatter;
return (
...
<div>
{if (props.student.length == null && props.teacher.length == null) => (
<p>empty</p>
) : (
<p>not empty</p>
)}
</div>
...
)
如何检查两个数组是否为空?
How can i check if both arrays are empty?
推荐答案
存在语法错误,您正在测试lambda表达式.
There is a syntax error, you are testing an lambda expression.
您可以做类似
return !!props.student.length && !!props.teacher.length ? <p>not empty</p> : <p>empty</p>;
这篇关于ES6条件if语句,用于检查数组是否为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文