美文网首页
node环境中使用express的常用方法总结

node环境中使用express的常用方法总结

作者: 我的昵称好听吗 | 来源:发表于2018-10-25 12:47 被阅读0次
1.获取用户当前客户端的userAgent
var user_agent  = res.headers["user-agent"].toLowerCase();
//判断是否是手机端
var is_mobile = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(user_agent );
2. 获取当前url协议(http/https)
res.protocol;
3.获取hostname
// Host: "example.com:3000"
req.hostname
// => "example.com"

持续更新中……

相关文章

网友评论

      本文标题:node环境中使用express的常用方法总结

      本文链接:https://www.haomeiwen.com/subject/grbqtqtx.html