小程序要做一个左滑显示删除Button
如下图:
找到 taro-ui组件 <atSwipeAction>
把代码Copy过来发现根本没啥效果
<AtSwipeAction options={[
{
text: '取消',
style: {
backgroundColor: '#6190E8'
}
},
{
text: '确认',
style: {
backgroundColor: '#FF4949'
}
}
]}>
<View className='normal'>AtSwipeAction 一般使用场景</View>
</AtSwipeAction>
查资料发现文档上 少写了两个重要的属性 maxDistance、areaWidth
应该为
<AtSwipeAction
maxDistance={80}
areaWidth={Taro.getSystemInfoSync().windowWidth*0.88} // 适配不同手机系统屏幕宽度
options={[
{
text: '取消',
style: {
backgroundColor: '#6190E8'
}
},
{
text: '确认',
style: {
backgroundColor: '#FF4949'
}
}
]}>
<View className='normal'>AtSwipeAction 一般使用场景</View>
</AtSwipeAction>
还要注意<AtSwipeAction> 父组件的定位不要为 absolute
Taro 官方文档有点过分了......