This commit is contained in:
shikong 2024-10-17 16:34:47 +08:00
parent 7f51077706
commit 7863c1ba57
Signed by: Shikong
GPG Key ID: BD85FF18B373C341

View File

@ -7,11 +7,18 @@ const ctx = reactive({
capsuleWidth: 0,
search: {
keyword: ""
},
safeAreaInsets: {
top: 0
}
})
let capsule = uni.getMenuButtonBoundingClientRect(); //
let system = uni.getSystemInfoSync(); //
let {safeAreaInsets} = system
console.log(system, safeAreaInsets)
ctx.safeAreaInsets = safeAreaInsets
ctx.navHeight = system.statusBarHeight + capsule.height; //
ctx.statusBarHeight = system.statusBarHeight //
ctx.capsuleWidth = capsule.width; //
@ -28,15 +35,8 @@ function searchKeyword() {
</script>
<template>
<view class="navbar" :style="{ minHeight: ctx.navHeight + 'px' }" style="background: #1296db">
<view
class="topInfo"
:style="{
paddingTop: ctx.statusBarHeight + 'px',
paddingRight: ctx.capsuleWidth + 'px',
}">
<uni-search-bar v-model="ctx.search.keyword" bgColor="#EEEEEE" placeholder="请输入搜索内容" @confirm="searchKeyword" cancelButton="none"></uni-search-bar>
</view>
<view :style="{paddingTop: ctx.safeAreaInsets.top + 'px', paddingRight: ctx.capsuleWidth + 'px'}" style="background: #1296db">
<uni-search-bar v-model="ctx.search.keyword" bgColor="#EEEEEE" placeholder="请输入搜索内容" @confirm="searchKeyword" cancelButton="none"></uni-search-bar>
</view>
</template>