ios 刘海屏怎么设置?
3***@qq.com
- 发布:2019-04-22 16:52
- 更新:2019-04-23 12:08
- 阅读:3452
2 个回复
DCloud_heavensoft
uni-app 为 iOS(iPhoneX)底部安全区适配:http://ask.dcloud.net.cn/article/35564
3***@qq.com (作者)
已解决 头部样式加这个。。height: env(safe-area-inset-top);
但是要区分苹果和安卓的。
<template>
<view class="status_bar" :style="{height:platform=='ios'?'env(safe-area-inset-top)':statusBarHeight} ">
<view class="top_view" :style="{height:platform=='ios'?'env(safe-area-inset-top)':statusBarHeight} "></view>
</view>
</template>
<script>
export default {
data: {
statusBarHeight: '' ,
platform:''
},
created() {
let _t = this;
setTimeout(() => { //获取状态栏高度,setTimeout后才能调用uni.
uni.getSystemInfo({
success: function(res) {
_t.statusBarHeight = res.statusBarHeight;
_t.platform= res.platform;
}
});
}, 1);
}
};
</script>
<stype>
.status_bar {
height: var(--status-bar-height);
width: 100%;
background: #fff;
}
</stype>