小程序uview actionSheet 内容过多高度设置

问题:u-action-sheet滚动不了

<u-action-sheet :list="list" v-model="show" @click="xxx"></u-action-sheet>

使用uview ui :u-action-sheet, 但是item太多,超出屏幕没法滚动, 去查官方文档的时候发现并没有设置滚动的属性

官方文档:ActionSheet 操作菜单 | uView 2.0 - 全面兼容 nvue 的 uni-app 生态框架 - uni-app UI 框架

解决办法:

第一步:修改源码

我这里用的HB转译的小程序,路径如下

找到node_modules -> uview_ui -> components -> u-action-sheet -> u-action-sheet.vue

复制代码
<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>
    <!-- 增加个循环在block外层 -->
    <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>

这个时候在电脑上是可以滚动的,但是手机不行

第二步:删除禁用触摸事件

还是源码的位置,可以看到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>
    <!-- 增加个循环在block外层 -->
    <scroll-view scroll-y style="min-height: 100rpx;max-height: 700rpx;">
		<block v-for="(item, index) in list" :key="index">
            <!-- @touchmove.stop.prevent -->
			<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页面

复制代码
<u-action-sheet :list="list" v-model="show" @click="xxxx"></u-action-sheet>
<!-- 在data里定义list数组对象 -->

这样就可以了

相关推荐
ybb_ymm5 小时前
从需求开始至架构设计的适用于商家及小吃摊的点餐小程序
小程序·apache
2501_915106326 小时前
HTTPS 爬虫实战指南 从握手原理到反爬应对与流量抓包分析
爬虫·网络协议·ios·小程序·https·uni-app·iphone
2501_916007476 小时前
iOS 上架技术支持全流程解析,从签名配置到使用 开心上架 的实战经验分享
android·macos·ios·小程序·uni-app·cocoa·iphone
阿登林6 小时前
如何利用扣子生成小程序并进行发布指南
小程序·扣子
流***陌16 小时前
手办盲盒抽赏小程序前端功能设计:兼顾收藏需求与抽赏乐趣
前端·小程序
Tencent_TCB16 小时前
云开发CloudBase AI+实战:快速搭建AI小程序全流程指南
人工智能·ai·小程序·ai编程·云开发
说私域18 小时前
“开源AI大模型AI智能名片S2B2C商城小程序”视角下的教育用户策略研究
人工智能·小程序
2501_9160074721 小时前
提升 iOS 26 系统流畅度的实战指南,多工具组合监控
android·macos·ios·小程序·uni-app·cocoa·iphone
一匹电信狗1 天前
【MySQL】数据库表的操作
linux·运维·服务器·数据库·mysql·ubuntu·小程序