uview 中的u-sticky u-tabs 修改成员间隔

在使用uview 中的u-sticky u-tabs组件时,可能需要修改成员之间的间隔。但是u-tabs并没有提供修改成员间隔属性,所以需要穿透样式实现。

修改之前代码及样式如下:

  <view class="wrapper">
    <u-sticky bgColor="#fff">
      <u-tabs
        :list="tabList"
        lineWidth="50"
        :activeStyle="{ color: '#2678FFFF' }"
      ></u-tabs>
    </u-sticky>
  </view>

共享工位 ,预定详情 ,固定工位 三者之间的间隔有点小,怎么变大呢?



.wrapper {
  background: rgb(227, 236, 250);
  padding-bottom: 100rpx;
  min-height: 100vh;
  ::v-deep .u-sticky {
    height: 100rpx;
    display: flex;
    justify-content: center;
  }
  ::v-deep .u-tabs__wrapper__nav__item {
    padding: 0 32rpx;
  }
}

 修改后的效果如下:

 

 

onReachBottom触底函数用这个但是无法保证搜索框和u-tabs标签页是吸顶的,该怎么解决?<template> <view class="deliveryOrder"> <u-toast ref="uToast"></u-toast> <view class="searchBtn"> <u-search placeholder="订单号" :showAction="true" v-model="orderValue" shape="round" actionText="查询" :animation="true" @search="searchClick()" @custom="searchClick()"></u-search> <text class="screening" @click="handleScreening">筛选</text> </view> <view class="tabsBox"> <u-sticky bgColor="#fff"> <u-tabs :list="list" :is-scroll="false" :current="current" bar-width="50" active-color="orange" @change="change"> </u-tabs> <view v-if="current===0"> <scroll-view @scrolltolower="lowerBottom" @refresherrefresh="getFresh" :refresher-enabled="true" :refresher-triggered="triggered" scroll-y="true" class="scrollHeight"> <view class="scrolllist" v-if="allList&&allList.length>0"> <view class="orderscrollItem" v-for="(item,index) in allList" :key="index" @click="toDetail(item)"> <view class="itemTitle"> {{item}} </view> </view> <view class="more_text" v-if="showMoreData"> 没有更多数据了... </view> </view> <view v-else class="empty_box"> <u-empty mode="order" icon="http://cdn.uviewui.com/uview/empty/car.png" > </u-empty> </view> </scroll-view> </view> <view v-if="current===1"> 待配送 </view> <view v-if="current===2"> 配送中 </view> <view v-if="current===3"> 待签收 </view> <view v-if="current===4"> 已完成 </view> </u-sticky> </view> <u-popup :show="showPopup" :round="10" mode="top" @close="showPopup=false"> <view class="popup"> <text class="popupTitle">筛选条件</text> <view class="formBox"> <u--form :model="form" ref="uForm" labelWidth="90px"> <u-form-item label="时间范围" prop="timeValue" borderBottom @click="showCalendar=true"> <u-input v-model="form.timeValue" :disabled="true" r
最新发布
03-28
UView Plus 的 `up-tabs` 组件如果设置了左右滚动并且其父元素有 `sticky-top` 粘性顶部的样式,可能会因为这两个特性冲突而影响滚动效果。为了解决这个问题,你可以尝试以下几个步骤: 1. **检查CSS优先级**:确保 `sticky-top` 的样式没有高于 `overflow-x: auto;` 或者 `scroll` 的优先级。可以尝试降低 `sticky-top` 的 z-index 或者修改它的样式为相对定位(position: relative;),这样不会阻止滚动。 ```css .parent-element { position: relative; overflow-x: auto; /* 或者使用 scroll */ -webkit-sticky: top; /* 修改 sticky 为 webkit-sticky */ /* 如果需要顶部固定,可以在屏幕滚动时动态添加/fade out 类 */ &.with-scroll { position: -webkit-sticky; /* 使用兼容的写法 */ } } ``` 2. **事件监听**:当 `up-tabs` 元素开始滚动时,移除 `.parent-element` 的 `sticky-top` 样式,当滚动结束再恢复。这通常通过 JavaScript 实现,比如 Vue、React 中可以监听滚动事件。 ```javascript export default { mounted() { window.addEventListener(&#39;scroll&#39;, this.handleScroll); }, beforeDestroy() { window.removeEventListener(&#39;scroll&#39;, this.handleScroll); }, methods: { handleScroll(e) { const parentEl = this.$refs.parentElement; if (parentEl && parentEl.scrollTop > 0) { // 移除 sticky-top 样式 parentEl.classList.remove(&#39;with-scroll&#39;); } else { // 恢复 sticky-top 样式 parentEl.classList.add(&#39;with-scroll&#39;); } } } }; ``` 3. **自定义滚动组件**:如果你能控制 `up-tabs` 和父元素的结构,考虑将滚动部分封装成独立的组件,并处理滚动和粘性布局的问题,让它们互不影响。 记得在上述解决方案中替换 `parent-element`、`.with-scroll` 以及对应的引用和选择器到实际的DOM元素上。如果问题依然存在,检查一下是否有其他 CSS 冲突或者浏览器兼容性问题。如果不确定,提供具体的代码片段会更容易找到解决方案。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值