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開源軟件。