if(typeof window !== undefined) {
console.log("this should print only if window object actually exists")
}
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我为什么在检查窗口是否未定义时NodeJS(0.6.5)无法正常工作?如果你调用typeof window,你会得到未定义但仍然无法正常工作.有任何想法吗?
if(typeof window !== 'undefined') {
console.log("this should print only if window object actually exists")
}
Run Code Online (Sandbox Code Playgroud)
typeof返回一个字符串
| 归档时间: |
|
| 查看次数: |
1597 次 |
| 最近记录: |