safeAreaInsets
使用javascript獲取安全區資訊.
先決條件
- WKWebview
- viewport-fit=cover
安裝
NPM
npm install safe-area-insets --save
複製程式碼
UMD
https://unpkg.com/safe-area-insets/out/umd/index.min.js
複製程式碼
使用
引用
var safeAreaInsets = require('safe-area-insets')
複製程式碼
安全區資訊
console.log('safeAreaInsets.support', safeAreaInsets.support)
console.log('safe-area-inset-top', safeAreaInsets.top)
console.log('safe-area-inset-left', safeAreaInsets.left)
console.log('safe-area-inset-right', safeAreaInsets.right)
console.log('safe-area-inset-bottom', safeAreaInsets.bottom)
複製程式碼
監聽安全區資訊變化事件
safeAreaInsets.onChange(function(style) {
console.log(style)
})
複製程式碼