Taro UI AtSwipeAction不生效解决方法

383 阅读1分钟

问题描述

taroui版本如下:

"taro-ui": "^3.0.0-alpha.3"

使用SwipeAction没有生效

解决方法

官方文档书没写全,需要另外添加两个属性
1.maxDistance 滑块最大滑动距离
2.areaWidth 组件宽度 (如果不引用会导致组件占位宽度为0,不会显示)

  <AtSwipeAction
          maxDistance={70}
          areaWidth={Taro.getSystemInfoSync().windowWidth * 0.88} // 适配不同手机系统屏幕宽度
          autoClose
          options={[
            {
              text: '取消',
              style: {
                backgroundColor: '#6190E8'
              }
            },
            {
              text: '确认',
              style: {
                backgroundColor: '#FF4949'
              }
            }
          ]}
        >
          <View className='playerCardStyle'>AtSwipeAction 一般使用场景</View>
        </AtSwipeAction>

修改后 界面效果如下:
在这里插入图片描述
在这里插入图片描述

参考文档

Taro SwipeAction 滑动操作