device.js
v2.0.0
المكتبة التفاعلية لمراقبة المتصفح الأساسي وخصائص الجهاز.
️ الإصدار 2 غير متوافق مع الإصدار 1. تحقق من changelog لمزيد من التفاصيل.
chrome, safari, firefox, facebook, instagram, edge, ie, opera, phantomjswebp, webrtc, webgl, pwaportrait, landscapedesktop, mobile, tablet, tvandroid, ios, windows, macoswidth, height yarn add @maoosi/device.jsالاستخدام الأساسي:
سيقوم هذا الرمز بتسجيل viewportWidth بعد كل تغيير حجم عرض ، اختنق إلى 200 مللي ثانية:
import { device , watch } from '@maoosi/device.js'
watch ( async ( ) => {
console . log ( device . viewportWidth )
} ) device هو كائن وكبير تفاعلي يمكن ملاحظته ويعرض الخصائص التالية:
interface device {
deviceOS : string | null
deviceType : string | null
deviceOrientation : string | null
browser : string | null
browserVersion : string | null
viewportHeight : number | null
viewportWidth : number | null
isBrowserEvergreen : boolean | null
isPWA : boolean | null
isSupportedWebP : boolean | null
isSupportedWebGL : boolean | null
isSupportedWebRTC : boolean | null
}باستخدام vue.js:
نظرًا لأن device كائن وكبير تفاعلي ، يمكن لـ Vue.js مراقبة التغييرات دون الحاجة إلى استخدام طريقة watch :
< template >
< pre > {{ deviceInfo }} </ pre >
</ template >
< script >
import { device } from '@maoosi/device.js'
export default {
data ( ) {
return { deviceInfo : device }
}
}
</ script > أولاً ، تأكد من تثبيت خدمة النماذج الأولية vue.js: https://cli.vuejs.org/guide/prototyping.html
ثم من المحطة الخاصة بك:
yarn playgroundالمساهمات والقضايا وطلبات الميزات موضع ترحيب.
حقوق الطبع والنشر © 2021 Maoosi.
هذا المشروع مرخص معهد ماساتشوستس للتكنولوجيا.