在node.js里面可以使用window对象的方法吗
巴扎黑
巴扎黑 2017-04-17 16:13:57
0
3
330

比如说window.location.href之类

巴扎黑
巴扎黑

reply all(3)
伊谢尔伦

window是浏览器的规范,并非js语言规范,所以在nodejs当然不能用。
不过nodejs有个类似的全局变量,叫golgal,当然了,它内部的内容和浏览器中的windowIt’s just very different.

大家讲道理

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

PHPzhong

Definitely not possible, the location belongs to the BOM, right, only the client has it...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template