伊谢尔伦2017-04-17 16:15:57
window
是浏览器的规范,并非js语言规范,所以在nodejs
当然不能用。
不过nodejs
有个类似的全局变量,叫golgal
,当然了,它内部的内容和浏览器中的window
It’s just very different.
大家讲道理2017-04-17 16:15:57
Why do we need to get window in node?
If you need to execute it, you can write it into html when rendering,
but it is strongly not recommended!!
<!-- html -->
<script>
window.localStorage.test = '123'
</script>
The best way is to use client logic + interface
PHPz2017-04-17 16:15:57
Definitely not possible, the location belongs to the BOM, right, only the client has it...