点击后会触发一个操作。
代码演示
类型、尺寸
button
import { Button, WhiteSpace, WingBlank } from 'antd-mobile';
const ButtonExample = () => (
<WingBlank>
<Button>default</Button><WhiteSpace />
<Button disabled>default disabled</Button><WhiteSpace />
<Button type="primary">primary</Button><WhiteSpace />
<Button type="primary" disabled>primary disabled</Button><WhiteSpace />
<Button type="warning">warning</Button><WhiteSpace />
<Button type="warning" disabled>warning disabled</Button><WhiteSpace />
<Button loading>loading button</Button><WhiteSpace />
<Button icon="check-circle-o">with icon</Button><WhiteSpace />
<Button icon={<img src="https://gw.alipayobjects.com/zos/rmsportal/jBfVSpDwPbitsABtDDlB.svg" alt="" />}>with custom icon</Button><WhiteSpace />
<Button icon="check-circle-o" inline size="small" style={{ marginRight: '4px' }}>with icon and inline</Button>
<Button icon="check-circle-o" inline size="small">with icon and inline</Button>
<WhiteSpace />
{/* <Button activeStyle={false}>无点击反馈</Button><WhiteSpace /> */}
{/* <Button activeStyle={{ backgroundColor: 'red' }}>custom feedback style</Button><WhiteSpace /> */}
<WhiteSpace />
<Button type="primary" inline style={{ marginRight: '4px' }}>inline primary</Button>
{/* use `am-button-borderfix`. because Multiple buttons inline arranged, the last one border-right may not display */}
<Button type="ghost" inline style={{ marginRight: '4px' }} className="am-button-borderfix">inline ghost</Button>
<WhiteSpace />
<Button type="primary" inline size="small" style={{ marginRight: '4px' }}>primary</Button>
<Button type="primary" inline size="small" disabled>primary disabled</Button>
<WhiteSpace />
<Button type="ghost" inline size="small" style={{ marginRight: '4px' }}>ghost</Button>
{/* use `am-button-borderfix`. because Multiple buttons inline arranged, the last one border-right may not display */}
<Button type="ghost" inline size="small" className="am-button-borderfix" disabled>ghost disabled</Button>
</WingBlank>
);
ReactDOM.render(<ButtonExample />, mountNode);
应用场景示例
examples with List / Flex
import { Button, List } from 'antd-mobile';
const ComplexButtonDemo = () => (
<List style={{ margin: '5px 0', backgroundColor: 'white' }}>
<List.Item
extra={<Button type="ghost" size="small" inline>small</Button>}
multipleLine
>
Regional manager
<List.Item.Brief>
Can be collected, refund, discount management, view data and other operations
</List.Item.Brief>
</List.Item>
<List.Item
extra={<Button type="primary" size="small" inline>small</Button>}
multipleLine
>
Regional manager
<List.Item.Brief>
Can be collected, refund, discount management, view data and other operations
</List.Item.Brief>
</List.Item>
</List>
);
ReactDOM.render(<ComplexButtonDemo />, mountNode);
API
属性 | 说明 | 类型 | 默认值 |
---|
type | 按钮类型,可选值为primary /ghost /warning 或者不设 | string | - |
size | 按钮大小,可选值为large 、small | string | large |
activeStyle | 点击反馈的自定义样式 (设为 false 时表示禁止点击反馈) | {}/false | {} |
activeClassName | 点击反馈的自定义类名 | string | |
disabled | 设置禁用 | boolean | false |
onClick | 点击按钮的点击回调函数 | (e: Object): void | 无 |
style | 自定义样式 | Object | 无 |
inline | 是否设置为行内按钮 | boolean | false |
loading | 设置按钮载入状态 | boolean | false |
icon | 可以是 Icon 组件里内置的某个 icon 的 type 值,也可以是任意合法的 ReactElement (注意: loading 设置后此项设置失效) | string /React.Element | - |
prefixCls | class前缀 | string | am-button |
className | 样式类名 | string | 无 |