用工小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.2 KiB

6 months ago
  1. # Platform.js v1.3.5
  2. A platform detection library that works on nearly all JavaScript platforms.
  3. ## Disclaimer
  4. Platform.js is for informational purposes only & **not** intended as a substitution for feature detection/inference checks.
  5. ## Documentation
  6. * [doc/README.md](https://github.com/bestiejs/platform.js/blob/master/doc/README.md#readme)
  7. * [wiki/Changelog](https://github.com/bestiejs/platform.js/wiki/Changelog)
  8. * [wiki/Roadmap](https://github.com/bestiejs/platform.js/wiki/Roadmap)
  9. * [platform.js demo](https://bestiejs.github.io/platform.js/) (See also [whatsmyua.info](https://www.whatsmyua.info/) for comparisons between platform.js and other platform detection libraries)
  10. ## Installation
  11. In a browser:
  12. ```html
  13. <script src="platform.js"></script>
  14. ```
  15. In an AMD loader:
  16. ```js
  17. require(['platform'], function(platform) {/*…*/});
  18. ```
  19. Using npm:
  20. ```shell
  21. $ npm i --save platform
  22. ```
  23. In Node.js:
  24. ```js
  25. var platform = require('platform');
  26. ```
  27. Usage example:
  28. ```js
  29. // on IE10 x86 platform preview running in IE7 compatibility mode on Windows 7 64 bit edition
  30. platform.name; // 'IE'
  31. platform.version; // '10.0'
  32. platform.layout; // 'Trident'
  33. platform.os; // 'Windows Server 2008 R2 / 7 x64'
  34. platform.description; // 'IE 10.0 x86 (platform preview; running in IE 7 mode) on Windows Server 2008 R2 / 7 x64'
  35. // or on an iPad
  36. platform.name; // 'Safari'
  37. platform.version; // '5.1'
  38. platform.product; // 'iPad'
  39. platform.manufacturer; // 'Apple'
  40. platform.layout; // 'WebKit'
  41. platform.os; // 'iOS 5.0'
  42. platform.description; // 'Safari 5.1 on Apple iPad (iOS 5.0)'
  43. // or parsing a given UA string
  44. var info = platform.parse('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7.2; en; rv:2.0) Gecko/20100101 Firefox/4.0 Opera 11.52');
  45. info.name; // 'Opera'
  46. info.version; // '11.52'
  47. info.layout; // 'Presto'
  48. info.os; // 'Mac OS X 10.7.2'
  49. info.description; // 'Opera 11.52 (identifying as Firefox 4.0) on Mac OS X 10.7.2'
  50. ```
  51. ## Support
  52. Tested in Chrome 82-83, Firefox 77-78, IE 11, Edge 82-83, Safari 12-13, Node.js 4-14, & PhantomJS 2.1.1.
  53. ## BestieJS
  54. Platform.js is part of the BestieJS *“Best in Class”* module collection. This means we promote solid browser/environment support, ES5+ precedents, unit testing, & plenty of documentation.