小程序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数组对象 -->

这样就可以了

相关推荐
Yu_iChan11 分钟前
苍穹外卖Day06 微信小程序模块
微信小程序·小程序
万岳科技系统开发18 小时前
付费知识系统源码的整体架构设计与模块划分
java·数据库·小程序
2501_9159214318 小时前
iOS App 中 SSL Pinning 场景下代理抓包失效的原因
android·网络协议·ios·小程序·uni-app·iphone·ssl
一品威客爱开发19 小时前
情绪识别技术优化客服 App 体验:让服务更贴心高效!
小程序
Brduino脑机接口技术答疑1 天前
SSVEP 脑电小程序说明
人工智能·机器学习·小程序·脑机接口
hello kitty w1 天前
1.标签定义
小程序
说私域1 天前
点状打法在电商与社群空间中的创新实践:基于开源链动2+1模式AI智能名片S2B2C商城小程序的探索
人工智能·小程序·开源
OctShop大型商城源码1 天前
免费开源大型多用户多商家小程序电商系统源码_OctShop
微信小程序·小程序·开源·小程序电商系统·多用户商城系统
2501_916008891 天前
在 Windows 上使用开心上架(Appuploader)在 Windows 环境下创建与管理 iOS 证书
android·ios·小程序·https·uni-app·iphone·webview
小白变怪兽1 天前
微信小程序页面中监听globalData数据变化
微信小程序·小程序