判断global对象,如果是window,就是运行在浏览器中,如果global对象是undefined,则运行在node中。 转载于:https://www.cnblogs.com/wuqilang/p/11253204.html