SwipeAction 滑动或长按操作
滑动( iOS )或长按( android )操作组件。定义/Definition
结合手势操作,从屏幕唤出删除键。规则 / Rule
一次只可滑动一行列表
点击任意删除按钮之外任意处或往回滑动该列表可撤销该操作。
代码演示
import { SwipeAction, List } from 'antd-mobile';
const SwipeActionExample = React.createClass({
render() {
return (
<List>
<List.Body>
<SwipeAction
style={{ backgroundColor: 'gray' }}
autoClose
right={[
{
text: '取消',
onPress: () => console.log('取消'),
style: { backgroundColor: '#ccc', color: 'white' },
},
{
text: '删除',
onPress: () => console.log('删除'),
style: { backgroundColor: '#FE7A38', color: 'white' },
},
]}
left={[
{
text: '回复',
onPress: () => console.log('查找'),
style: { backgroundColor: '#2DB7F5', color: 'white' },
},
{
text: '取消',
onPress: () => console.log('取消'),
style: { backgroundColor: '#ccc', color: 'white' },
},
]}
onOpen={() => console.log('global open')}
onClose={() => console.log('global close')}
>
<List.Item
extra="更多"
arrow="horizontal"
>
左右都可操作
</List.Item>
</SwipeAction>
</List.Body>
</List>
);
},
});
ReactDOM.render(<SwipeActionExample />, mountNode);
API
SwipeAction
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
prefixCls (web only) | className prefix | String | rc-swipeout |
style | swipeout style (iOS only) | Object | |
left | swipeout buttons on left | Array | null |
right | swipeout buttons on right | Array | null |
autoClose | auto close on button press | Boolean | function() {} |
onOpen | Function | function() {} | |
onClose (web only) | Function | function() {} | |
disabled | disabled swipeout | Boolean | false |
title | modal title (android only) | String | 请确认操作 |
Button
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
text | button text | String | Click |
style | button style (iOS only) | Object |
|
onPress | button press function | Function | function() {} |