uniapp 手机端滚动不可用问题解决

我在写h5页面的时候,遇到了几次滚动不能用的问题,(正常页面上没有,但是弹窗中就是滑动不了),还是记一下吧

问题代码

<Drawer
    ref="showRight"
    mode="left"
    :mask-click="true"
    :width="clientWidth"
    :height="320"
  >
    <view class="flex-col items-center content">
      <view
        v-for="(item, index) in dataList"
        :key="item.id"
        @click="
          () => {
            clickobj = item;
          }
        "
        class="flex-row justify-center items-center listItem"
        :class="clickobj.id == item.id ? 'activity' : ''"
      >
        {{ item.name }}</view
      >
    </view>
    <view class="submit" @click="emitBack"> 确定 </view>
  </Drawer>

<Drawer>是我封装的弹窗

其中的样式也是看起来没什么问题,当然,高是要固定好的,我这里用的max-height

.content {
  padding: 34px 0px 35px;
  max-height: 195px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.listItem {
  width: 100%;
  height: 40px;
}
.activity {
  color: $uni-color-primary;
}
.submit {
  width: 100%;
  height: 55px;
  line-height: 55px;
  text-align: center;
  color: $uni-text-color-inverse;
  background-color: $uni-color-primary;
}

可就是不能滑动

解决办法:

将需要滑动的 <view> 直接变成 <scroll-view>就好,并加上属性 scroll-y="true" ,并且没有改样式,就解决了

<Drawer
    ref="showRight"
    mode="left"
    :mask-click="true"
    :width="clientWidth"
    :height="320"
  >
    <scroll-view scroll-y="true" class="flex-col items-center content">
      <view
        v-for="(item, index) in dataList"
        :key="item.id"
        @click="
          () => {
            clickobj = item;
          }
        "
        class="flex-row justify-center items-center listItem"
        :class="clickobj.id == item.id ? 'activity' : ''"
      >
        {{ item.name }}</view
      >
    </scroll-view>
    <view class="submit" @click="emitBack"> 确定 </view>
  </Drawer>

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值