Welink React-ui表单组件Button
Button
按钮。Button UI 提供与WeLink规范一致的视图。 按钮的类型包括:页面主操作、页面次要操作、警告类操作和页面一般操作。
参数说明
参数 | 类型 | 默认值 | 说明 |
---|---|---|---|
type | string | 'primary' | 按钮的类型,可选值:primary,default,warn primary:页面主操作 default:页面次要操作 warn:警告类操作 |
size | string | - | 按钮的大小,可选值:normal,small |
plain | bool | false | 是否为白色背景 |
icon | component | - | 按钮图标 |
import React from 'react';
import { Button, ButtonArea } from '@wecode/react-weui';
import './button.less';
const imgStyle = { display: 'inline-block', verticalAlign: 'middle' };
export default class ButtonDemo extends React.Component {
state = {
btnType: 'spacingBtns'
};
handleChangeValue = (key, value) => {
this.setState({ [key]: value });
};
clickBtns(type) {
this.setState({ btnType: type });
}
render() {
const { btnType } = this.state;
return (
<div>
<section>
{btnType === 'spacingBtns' ? (
<ButtonArea fixedSpacing>
<Button type="warn">取消</Button>
<Button type="primary">确定</Button>
</ButtonArea>
) : null}
{btnType === 'btns' ? (
<ButtonArea fixed>
<Button type="warn">取消</Button>
<Button type="primary">确定</Button>
</ButtonArea>
) : null}
{btnType === 'sureBtn' ? (
<ButtonArea fixedSpacing>
<Button type="primary">确定</Button>
</ButtonArea>
) : null}
{btnType === 'deleteBtn' ? (
<ButtonArea fixedSpacing>
<Button type="warn">删除</Button>
</ButtonArea>
) : null}
<div>
<Button>页面主操作 Normal</Button>
<Button disabled>页面主操作 Disabled</Button>
<Button type="warn">警告类操作 Normal</Button>
<Button type="warn" disabled>
警告类操作 Normal
</Button>
</div>
<div className="page__bd page__bd_spacing button-sp-area__item">
<Button type="primary" size="small" plain>
四字按钮
</Button>{' '}
<Button type="default" size="small" plain>
四字按钮
</Button>
</div>
<div className="page__bd page__bd_spacing button-sp-area__item">
<Button size="small">Mini</Button>
</div>
<div className="button-sp-area button-sp-area__item">
<Button
type="primary"
size="small"
plain
icon={(
<img
alt="加入会议"
src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbm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w1Ljk3NDEyOTg4IEwxNC4xNDAxMzc5LDUuMDc5MjU1MDEgQzE0LjE5Nzc3NjQsNS4wMzg3MTYyNyAxNSw0LjU2MzgwODUxIDE1LDQuODkyMzg1NjUgTDE1LDExLjIzNDAzMTIgQzE1LDExLjU2MzY3NTIgMTQuMTk3Nzc2NCwxMS4wODgyMzQgMTQuMTAzOTgyOCwxMS4wMjg0OTI3IEwxMS44NTYwODAxLDEwLjAyMjY2OTcgTDExLjg1NjA4MDEsMTEuNDAzNjUzOCBDMTEuODU2MDgwMSwxMS43MzI3NjQ0IDExLjU5MzAzODgsMTIgMTEuMjcwMjYzMSwxMiBMMS41ODU4MTcwNywxMiBaIiBpZD0iRmlsbC0xIiBmaWxsPSIjMDM5QkU1Ij48L3BhdGg+CiAgICAgICAgICAgIDwvZz4KICAgICAgICA8L2c+CiAgICA8L2c+Cjwvc3ZnPg=="
style={imgStyle}
/>
)}
>
加入会议
</Button>
</div>
<div className="btn-tep-container">
<Button type="warn" size="middle">
中等按钮
</Button>
<Button type="primary" size="middle">
中等按钮
</Button>
</div>
<div className="page__bd page__bd_spacing button-sp-area__item">
<Button
type="primary"
size="small"
plain
onClick={() => {
this.clickBtns('spacingBtns');
}}
>
有间距双按钮
</Button>
<Button
type="primary"
size="small"
plain
onClick={() => {
this.clickBtns('btns');
}}
>
无间距双按钮
</Button>
<Button
type="primary"
size="small"
plain
onClick={() => {
this.clickBtns('sureBtn');
}}
>
确定单按钮
</Button>
<Button
type="primary"
size="small"
plain
onClick={() => {
this.clickBtns('deleteBtn');
}}
>
删除单按钮
</Button>
</div>
<br />
<br />
<br />
<br />
<br />
</section>
</div>
);
}
}
- 点赞
- 收藏
- 关注作者
评论(0)