svelte device detector
0.2.2
••
在不同的设备类型上呈现视图。
npm i svelte-device-detector
// OR
yarn add svelte-device-detector
注意:要在Sapper中使用此库,请以DevDectionenty安装。请参阅链接。
当地演示:
git clone https://github.com/andrelmlins/svelte-device-detector.git
cd svelte-device-detector
npm install && npm run dev
如何使用库的一个示例:
< script >
import DeviceDetector from "svelte-device-detector";
</ script >
< DeviceDetector showInDevice = "desktop" >
< p > Desktop </ p >
< / DeviceDetector>
< DeviceDetector showInBrowser = "chrome" showInDevice = "mobile" >
< p > Mobile and Chrome </ p >
</ DeviceDetector >
< DeviceDetector showInBrowser = { [ "safari" , "firefox" ] } >
< p > Safari or Firefox </ p >
< / DeviceDetector>为了获得最佳结果,值具有以下特征:
| 支柱 | 默认 | 类型 | 描述 |
|---|---|---|---|
| ShowIndevice | - | string , array | 对设备类型的渲染视图 |
| ShowInbrowser | - | string , array | 浏览器类型上的渲染视图 |
| Showinos | - | string , array | 对操作系统类型的渲染视图 |
下载此NPM软件包的统计信息
Svelte设备检测器被许可为MIT开源软件。