使用javascript获取安全区信息.
- WKWebview
- viewport-fit=cover
npm install safe-area-insets --save
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)
function callback(style){
console.log(style)
}
// add
safeAreaInsets.onChange(callback)
// remove
safeAreaInsets.offChange(callback)