Tag Archives: Taro SwipeAction Not Working

How to Fix Taro SwipeAction Not Working Issue

Invalid reason:

Because two attributes of the official document are not written, and we have not written them, it will not take effect
1 The maximum sliding distance of maxdistance slider is generally the number of buttons multiplied by the button width
2 Areawidth component width (if no reference causes the component occupancy width to be 0, the page will not be displayed)

be careful:

Here, the width in option must use PX, if you use rpx, there will be UI problems on different devices, maxDistance= the width length of two options, maxDistance is the type of number

Correct code:

<AtSwipeAction
  maxDistance={140} // Button width * number of buttons
  areaWidth={Taro.getSystemInfoSync().windowWidth * 1} //Dynamically get the width of different devices
  autoClose //click the button to close it automatically
  onClick={(option, btnIndex) => { }} //Click to cancel Triggered after deleting the button, one parameter is the currently clicked option item, the second parameter is the index of the button 0 1
  options={[
    {
      text: 'cancel',
      style: {
        justifyContent: 'center',
        width: '70px',
        padding: 0,
      }
    },
    {
      text: 'Delete',
      style: {
        justifyContent: 'center',
        width: '70px',
        padding: 0,
      }
    }
  ]}>
  <View>
    Content
  </View>
</AtSwipeAction>