uniapp uni-popup使用scroll-view滚动时,底部按钮设置position:fixed失效,部分ios设置有问题

uniapp uni-popup使用scroll-view滚动时,底部按钮设置position:fixed失效,部分ios设置有问题

尝试过多种办法,最后发现部分机型position:fixed失效,position: sticky可以用,但是只设置sticky的话,部分机型又会有问题,无法在最底部,所以想到了嵌套的方法。

FilterPopup.vue弹框组件

html 复制代码
<template>
  <!--设置page-meta,弹框打开时禁止滚动页面-->
  <page-meta :page-style="'overflow:'+(isShow?'hidden':'visible')"></page-meta>
  <!-- 筛选 -->
  <uni-popup ref="popupFilter" type="right" background-color="#fff" @change="popupChange">
    <scroll-view scroll-y="true" class="popup-content">
      <view class="main-cont">
        <slot/>
      </view>
      <view class="bottom-fixed-bg-cont-filter"></view>
      <!--给按钮的view再包一层view,设置sticky-->
      <view class="position-sticky" :class="tabBarFilter?'tabbar-btn':''">
        <view class="bottom-fixed-btn-cont">
          <button size="large" class="button" @click="handle('reset')">重置</button>
          <button size="large" class="button button-confirm" type="info" @click="handle('submit')">确认</button>
        </view>
      </view>
    </scroll-view>
  </uni-popup>
</template>
<script setup>
import {ref} from 'vue'

const props = defineProps({
  // 如果是带有tabBar页面的筛选项,tabBarFilter传true,查询重置按钮需要根据入参重设高度
  tabBarFilter: {
    type: Boolean || undefined,
    default: ''
  },
  customClose: { // 自行处理关闭
    type: Boolean,
    default: false
  }
})
const isShow = ref(false)
const emits = defineEmits(['submit', 'reset'])
const handle = (type) => {
  emits(type)
  if (props.customClose && type === 'submit') return;
  close()
}
const popupFilter = ref(null)

function open() {
  popupFilter.value.open()
}

function close() {
  popupFilter.value.close()
}

const popupChange = (e) => {
  isShow.value = e.show
}

defineExpose({
  open,
  close
})
</script>
<style scoped lang="scss">
.popup-content {
  width: 600rpx;
  height: 100vh;
  box-sizing: border-box;

  .main-cont {
    padding: 16rpx 54rpx 0 54rpx;
    box-sizing: border-box;
  }
}

.bottom-fixed-bg-cont-filter {
  // #ifdef H5
  height: 260rpx;
  // #endif
  // #ifndef H5
  height: 180rpx;
  // #endif
  padding-bottom: constant(safe-area-inset-bottom);
  padding-bottom: env(safe-area-inset-bottom);
}

.position-sticky {
  position: sticky;
}
.bottom-fixed-btn-cont {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 160rpx;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #ffffff;
  padding: 10rpx 20rpx;
  padding-bottom: constant(safe-area-inset-bottom);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: rgba(0, 0, 0, 0.08) 0 0 3px 1px;
}

</style>
相关推荐
小徐_23332 天前
uni-app vue3 也能使用 Echarts?Wot Starter 是这样做的!
前端·uni-app·echarts
iOS阿玮2 天前
永远不要站在用户的对立面,挑战大众的公知。
uni-app·app·apple
xw52 天前
uni-app中v-if使用”异常”
前端·uni-app
!win !2 天前
uni-app中v-if使用”异常”
前端·uni-app
2501_915918412 天前
iOS 上架全流程指南 iOS 应用发布步骤、App Store 上架流程、uni-app 打包上传 ipa 与审核实战经验分享
android·ios·小程序·uni-app·cocoa·iphone·webview
00后程序员张2 天前
iOS App 混淆与加固对比 源码混淆与ipa文件混淆的区别、iOS代码保护与应用安全场景最佳实践
android·安全·ios·小程序·uni-app·iphone·webview
00后程序员张3 天前
详细解析苹果iOS应用上架到App Store的完整步骤与指南
android·ios·小程序·https·uni-app·iphone·webview
海绵宝宝不喜欢侬3 天前
uniapp-微信小程序分享功能-onShareAppMessage
微信小程序·小程序·uni-app
2501_915106323 天前
Xcode 上传 ipa 全流程详解 App Store 上架流程、uni-app 生成 ipa 文件上传与审核指南
android·macos·ios·小程序·uni-app·iphone·xcode
xkxnq3 天前
Uniapp崩溃监控体系构建:内存泄漏三维定位法(堆栈/资源/线程)
uni-app