dingtalk only
SwipeActionSwipeAction 滑动操作
目前该组件库在钉钉小程序上,删除可能存在动画延迟的效果(微信小程序是好的),同比看了 vant 的 swipe-cell 也有同样的问题,疑似钉钉内核可能有问题,特此告知
代码示例
import { BfSwipeAction } from '@bud-fe/react-taro-ui';import { View } from '@tarojs/components';import React, { useState } from 'react';export default () => {const [test, setTest] = useState(false);const [_dataList, setDataList] = useState([{ id: 1, name: '3333' },{ id: 2, name: '4444' },{ id: 3, name: '5555' },{ id: 4, name: '6666' },]);return (<><View style={{ display: 'flex', flexDirection: 'column' }}>{_dataList.map((item, index) => (<View key={item.name}><BfSwipeActionkey={item.name}content={<View>{item.id}~{item.name}</View>}operation={[{text: '删除',key: item.name + '1',style: { color: '#ffffff', backgroundColor: '#FD3C42' },onClick: () => {// console.log(111);setDataList((pre) => {const oldList = [...pre];oldList.splice(index, 1);return oldList;});},},{ text: '预览', key: item.name + '2', style: 'color: #ffffff;background-color: #85673d' },]}operationWidth={270}onContentClick={() => console.log(22222222)}// autoClose/></View>))}<BfSwipeActionkey={6666}content={<View>这是奥迪姐我奥is的及附加爱睡觉</View>}height={640}operation={[{text: '删除',style: { color: '#ffffff', backgroundColor: '#FD3C42' },onClick: () => console.log(1111111),},{ text: '预览', style: { color: '#ffffff', backgroundColor: '#85673d' } },]}operationWidth={350}onContentClick={() => console.log(22222222)}autoCloseisOpened={test}onOpenChange={(opened) => {console.log('BfSwipeAction ====> ', opened);setTest(opened);}}/></View></>);};
API
属性名 | 描述 | 类型 | 默认值 |
---|---|---|---|
height | 高度,自动转换成rpx,传750设计稿大小 | number | 120 |
content | 内容item | any | -- |
operation | 操作按钮 | IBfSwipeActionOperation[] | -- |
renderOperationItem | 自定义操作样式 | (item: IBfSwipeActionOperation) => any | -- |
operationWidth | 滑块到底,自动转换成rpx,传750设计稿大小 | number | (必选) |
onContentClick | item点击 | () => void | -- |
disabled | 禁止滑动 | boolean | -- |
autoClose | 点击选项自动关闭 | boolean | -- |
isOpened | 是否开启 | boolean | -- |
onOpenChange | 滑块变化 | (opened: boolean) => void | -- |