if(thisname && thisname!==null){
thisname=thisname;
}
else{
thisname=i;
}
改写成:
(thisname && thisname!==null) ? thisname : i;
用if正常, 用三元运算,就出错了。 请问为什么?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
这代码。。。
看代码啊:thisname 为真,并且thisname不等于Null。
这句中thisname如果为null,肯定为假。
如果要我改:
thisname = 2
2
(thisname && thisname!==null) ? thisname : i;
2
chrome 没问题