1
为什么即使与IF检查,流量仍然会抱怨有可能空值为什么流量仍抱怨空值的document.getElementById
if(document && document.getElementById("myID") && document.getElementById("myID").offsetWidth){
console.log(document.getElementById("myID").offsetWidth);
}
给出了这样的错误
^property `offsetWidth`. Property cannot be accessed on possibly null value