当前位置: 首页 > news >正文

uview ui 1.x ActonSheet项太多,设置滚动

问题:ActionSheet滚动不了。

使用uview ui :u-action-sheet, 但是item太多,超出屏幕了, 查了一下文档,并没有设置滚动的地方。

官方文档:ActionSheet 操作菜单 | uView - 多平台快速开发的UI框架 - uni-app UI框架

解决

只能修改源码了,在v-for遍历外面添加一个滚动视图,即可,其他不变

<template><u-popup mode="bottom" :border-radius="borderRadius" :popup="false" v-model="value" :maskCloseAble="maskCloseAble"length="auto" :safeAreaInsetBottom="safeAreaInsetBottom" @close="popupClose" :z-index="uZIndex"><view class="u-tips u-border-bottom" v-if="tips.text" :style="[tipsStyle]">{{tips.text}}</view><scroll-view scroll-y style="min-height: 100rpx;max-height: 700rpx;"><block v-for="(item, index) in list" :key="index"><view@touchmove.stop.prevent@tap="itemClick(index)":style="[itemStyle(index)]"class="u-action-sheet-item u-line-1":class="[index < list.length - 1 ? 'u-border-bottom' : '']":hover-stay-time="150"><text>{{item.text}}</text><text class="u-action-sheet-item__subtext u-line-1" v-if="item.subText">{{item.subText}}</text></view></block></scroll-view><view class="u-gab" v-if="cancelBtn"></view><view @touchmove.stop.prevent class="u-actionsheet-cancel u-action-sheet-item" hover-class="u-hover-class":hover-stay-time="150" v-if="cancelBtn" @tap="close">{{cancelText}}</view></u-popup>
</template>

 效果:控制差不多半屏显示了,不超屏幕了。 在电脑上用鼠标滚轮很正常。但是在手机滚动不了。

问题2: 手机上触摸滚动不了。

再去看源码,发现包裹着block里的view禁止触摸事件,导致滚动视图滚动不了。把@touchmove.stop.prevent删除即可

最终代码

<template><u-popup mode="bottom" :border-radius="borderRadius" :popup="false" v-model="value" :maskCloseAble="maskCloseAble"length="auto" :safeAreaInsetBottom="safeAreaInsetBottom" @close="popupClose" :z-index="uZIndex"><view class="u-tips u-border-bottom" v-if="tips.text" :style="[tipsStyle]">{{tips.text}}</view><scroll-view scroll-y="true" style="min-height: 100rpx;max-height: 700rpx;"><block v-for="(item, index) in list" :key="index"><view@tap="itemClick(index)":style="[itemStyle(index)]"class="u-action-sheet-item u-line-1":class="[index < list.length - 1 ? 'u-border-bottom' : '']":hover-stay-time="150"><text>{{item.text}}</text><text class="u-action-sheet-item__subtext u-line-1" v-if="item.subText">{{item.subText}}</text></view></block></scroll-view><view class="u-gab" v-if="cancelBtn"></view><view @touchmove.stop.prevent class="u-actionsheet-cancel u-action-sheet-item" hover-class="u-hover-class":hover-stay-time="150" v-if="cancelBtn" @tap="close">{{cancelText}}</view></u-popup>
</template>

 .vue

//...
<view class="submenu"><u-action-sheet :list="subList" v-model="showSub" :tips="menuTitle" @click="selectSubMenu"></u-action-sheet></view>//...export default {components: {HeadNavBar},data() {return {menuTitle: {text: "运营管理"},subList: [{text: 'item1'}, {text: 'item2'}, {text: 'item3'}, {text: 'item4'}, {text: 'item5'},{text: 'item6'}, {text: 'item7'},{text: 'item8'}, {text: 'item9'},{text: 'item10'}, {text: 'item11'},{text: 'item12'}, {text: 'item13'}],showSub: false,}}
}//...

手机上效果:

http://www.lryc.cn/news/142294.html

相关文章:

  • 信息化发展2
  • ubuntu18 + ros2 eloquent +python3.6
  • 围棋与育种
  • Python第三方库纵览
  • 测试.net开源音频库NAudio
  • 三方接口调用设计方案
  • OLED透明屏全贴合技术:未来显示技术的突破性创新
  • map、sync.map、concurrent-map适用场景与源码解析
  • 分布式事物实现方案及优缺点
  • java使用@interface和反射来动态生成excel
  • 【微服务】04-Polly实现失败重试和限流熔断
  • 如何使用HTML5新增的标签来构建语义化的页面结构?
  • Vmware 虚拟机挂起恢复后发现无法 Ping 通,无法连接到主机
  • Web自动化测试之图文验证码的解决方案
  • 软考高级系统架构设计师系列论文九十:论分布式数据库的设计与实现
  • Day 84:网络结构与参数
  • vue2.6及以下版本导入 TDesign UI组件库
  • VR/AR/眼镜投屏充电方案(LDR6020)
  • 区分什么是Java内存模型(JMM)和 JVM运行时数据区
  • Flask狼书笔记 | 04_表单
  • RabbitMQ+springboot用延迟插件实现延迟消息的发送
  • 多线程和并发(1)—等待/通知模型
  • 浏览器的事件循环
  • 跳跃游戏 II【贪心算法】
  • promise
  • 前端面试:【网络协议与性能优化】HTTP/HTTPS、TCP/IP和WebSocket
  • 设计模式之工厂模式(万字长文)
  • CNN 02(CNN原理)
  • Android View动画整理
  • 阿里云架构