最佳解决方案
防止滚动穿透 只需加入@touchmove.native.stop.prevent 阻止默认根元素的默认事件就可以了,
native是关键,这个表示根元素的意思,也就是body或者html
阻止picker组件内滑动事件冒泡:
<template> <view class="lb-multi-selector lb-picker-item" @touchmove.native.stop.prevent :style="{ height: height }"> <picker-view :value="pickerValue" :indicator-style="indicatorStyle" :style="{ height: height }" @change="handleChange"> <picker-view-column v-for="(column, index) in pickerColumns" :key="index"> <view v-for="(item, i) in column || []" :class="[ 'lb-picker-column', item[props.value] === selectValue[index] ? 'lb-picker-column-active' : '' ]" :key="i"> <text class="lb-picker-column-label"> {{ item[props.label] || item }} </text> </view> </picker-view-column> </picker-view> </view> </template>
屏蔽确定栏的拖动事件:
<view class="lb-picker-header-actions" @touchmove.native.stop.prevent> <view class="lb-picker-action lb-picker-left"> <!-- 取消 --> <view class="lb-picker-action-item lb-picker-action-cancel" @tap.stop="handleCancel"> <slot v-if="$slots['cancel-text']" name="cancel-text"> </slot> <text v-else class="lb-picker-action-cancel-text" :style="{ color: cancelColor }"> {{ cancelText }} </text> </view> </view> <!-- 中间 --> <view class="lb-picker-action lb-picker-center" v-if="$slots['action-center']"> <slot name="action-center"></slot> </view> <!-- 确定 --> <view class="lb-picker-action lb-picker-right"> <view class="lb-picker-action-item lb-picker-action-confirm" @tap.stop="handleConfirm"> <slot v-if="$slots['confirm-text']" name="confirm-text"> </slot> <text v-else class="lb-picker-action-confirm-text" :style="{ color: confirmColor }"> {{ confirmText }} </text> </view> </view> </view>