前端代码如何判断是浏览器环境还是node环境 东倒西歪小田螺 2022-10-08 166 阅读1分钟 if(typeof XHLHttpRequest != 'undefined') { // 浏览器用的是xhr适配器 //你的代码 }else if(typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') { // node 用的是http适配器 //你的代码 }