【文件属性】:
文件名称:detect-browser:从useragent字符串解压缩浏览器类型和版本
文件大小:28KB
文件格式:ZIP
更新时间:2021-05-09 12:44:39
JavaScript
检测浏览器
此软件包尝试使用浏览器中的导航器用户代理或节点中的process.version来检测浏览器供应商和版本(以兼容semver的格式)。
安装
发行历史
发行历史记录可以在。
用法示例
const { detect } = require ( 'detect-browser' ) ;
const browser = detect ( ) ;
// handle the case where we don't detect the browser
if ( browser ) {
console . log ( browser . name ) ;
console . log ( browser . version ) ;
console . log ( browser . os ) ;
}
或者,您可以使用switch语句:
const { detect } =
【文件预览】:
detect-browser-master
----.gitignore(71B)
----package.json(2KB)
----tslint.json(171B)
----src()
--------index.ts(8KB)
----.travis.yml(93B)
----LICENSE(1KB)
----tsconfig.json(288B)
----examples()
--------switch.js(329B)
--------simple.js(219B)
--------use-discriminator.ts(659B)
----README.md(5KB)
----.npmignore(90B)
----test()
--------index.js(50B)
--------highLevel.js(562B)
--------logic.js(15KB)
----.prettierrc(39B)
----yarn.lock(32KB)