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