vue-device-detector
Version:
A tiny device detector plugin of vue for mobile
92 lines (67 loc) • 3.53 kB
Markdown
[](https://www.codacy.com/app/dreambo8563/vue-DeviceDetector?utm_source=github.com&utm_medium=referral&utm_content=dreambo8563/vue-DeviceDetector&utm_campaign=Badge_Grade)
[](#contributors)
[](https://travis-ci.com/dreambo8563/vue-DeviceDetector)
[](https://greenkeeper.io/)
[](https://snyk.io/test/github/dreambo8563/vue-DeviceDetector?targetFile=package.json)
[](https://opensource.org/licenses/MIT)


[](https://app.fossa.io/projects/git%2Bgithub.com%2Fdreambo8563%2Fvue-DeviceDetector?ref=badge_shield)
# vue-device-detector

**vue-device-detector** is a simple vue plugin to inspect the device type.
- focus on mobile
- vue friendly
- strong typed
TODO:
- [x] add dingding api
- [x] add weixin api
### Install
```cmd
npm install vue-device-detector --save
```
### Quick Start
```js
import device from "vue-device-detector"
Vue.use(device)
```
### Methods
- this.\$device in Component context.
- Vue.\$device in global.
### API list
you can get the following properties under this.\$device
```ts
interface IDeviceDetector {
ios: Boolean
iphone: Boolean
iphoneX: Boolean
iPhoneXR: Boolean
iPhoneXSMax: Boolean
ipod: Boolean
ipad: Boolean
android: Boolean
androidPhone: Boolean
windows: Boolean
mobile: Boolean
dingding: Boolean //钉钉
wechat: Boolean, // 微信
wechatMiniApp: Boolean //微信小程序
}
```
eg.
on iphoneX
```js
console.log(this.$device.iphoneX) // true
console.log(this.$device.ios) // true
console.log(this.$device.android) // false
```
## License
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fdreambo8563%2Fvue-DeviceDetector?ref=badge_large)
## Contributors
Thanks goes to these wonderful people ([emoji key](https://github.com/all-contributors/all-contributors#emoji-key)):
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore -->
| [<img src="https://avatars2.githubusercontent.com/u/6948318?v=4" width="100px;" alt="Vincent Guo"/><br /><sub><b>Vincent Guo</b></sub>](https://dreambo8563.github.io/)<br />[💻](https://github.com/dreambo8563/vue-DeviceDetector/commits?author=dreambo8563 "Code") [📖](https://github.com/dreambo8563/vue-DeviceDetector/commits?author=dreambo8563 "Documentation") [🚇](#infra-dreambo8563 "Infrastructure (Hosting, Build-Tools, etc)") |
| :---: |
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!