2019-11-21 20:23:56 +08:00
|
|
|
---
|
|
|
|
order: 2
|
|
|
|
title:
|
2019-12-03 13:33:04 +08:00
|
|
|
zh-CN: 骨架按钮和头像
|
|
|
|
en-US: Skeleton button and avatar
|
2019-11-21 20:23:56 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
2019-12-03 13:33:04 +08:00
|
|
|
骨架按钮和头像。
|
2019-11-21 20:23:56 +08:00
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
2019-12-03 13:33:04 +08:00
|
|
|
Skeleton button and avatar.
|
2019-11-21 20:23:56 +08:00
|
|
|
|
|
|
|
```jsx
|
|
|
|
import { Skeleton, Switch, Form, Radio } from 'antd';
|
|
|
|
|
|
|
|
class Demo extends React.Component {
|
|
|
|
state = {
|
2019-12-03 13:33:04 +08:00
|
|
|
buttonActive: false,
|
|
|
|
avatarActive: false,
|
|
|
|
buttonSize: 'default',
|
|
|
|
avatarSize: 'default',
|
|
|
|
buttonShape: 'default',
|
|
|
|
avatarShape: 'circle',
|
2019-11-21 20:23:56 +08:00
|
|
|
};
|
|
|
|
|
2019-12-03 13:33:04 +08:00
|
|
|
handleActiveChange = prop => checked => {
|
|
|
|
this.setState({ [prop]: checked });
|
2019-11-21 20:23:56 +08:00
|
|
|
};
|
|
|
|
|
2019-12-03 13:33:04 +08:00
|
|
|
handleSizeChange = prop => e => {
|
|
|
|
this.setState({ [prop]: e.target.value });
|
2019-11-21 20:23:56 +08:00
|
|
|
};
|
|
|
|
|
2019-12-03 13:33:04 +08:00
|
|
|
handleShapeChange = prop => e => {
|
|
|
|
this.setState({ [prop]: e.target.value });
|
2019-11-21 20:23:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
2019-12-03 13:33:04 +08:00
|
|
|
const {
|
|
|
|
buttonActive,
|
|
|
|
avatarActive,
|
|
|
|
buttonSize,
|
|
|
|
avatarSize,
|
|
|
|
buttonShape,
|
|
|
|
avatarShape,
|
|
|
|
} = this.state;
|
2019-11-21 20:23:56 +08:00
|
|
|
return (
|
|
|
|
<div>
|
2019-12-03 13:33:04 +08:00
|
|
|
<div>
|
|
|
|
<Form layout="inline" style={{ marginBottom: 16 }}>
|
|
|
|
<Form.Item label="ButtonActive">
|
|
|
|
<Switch checked={buttonActive} onChange={this.handleActiveChange('buttonActive')} />
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item label="ButtonSize">
|
|
|
|
<Radio.Group value={buttonSize} onChange={this.handleSizeChange('buttonSize')}>
|
|
|
|
<Radio.Button value="default">Default</Radio.Button>
|
|
|
|
<Radio.Button value="large">Large</Radio.Button>
|
|
|
|
<Radio.Button value="small">Small</Radio.Button>
|
|
|
|
</Radio.Group>
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item label="ButtonShape">
|
|
|
|
<Radio.Group value={buttonShape} onChange={this.handleShapeChange('buttonShape')}>
|
|
|
|
<Radio.Button value="default">Default</Radio.Button>
|
|
|
|
<Radio.Button value="round">Round</Radio.Button>
|
|
|
|
<Radio.Button value="circle">Circle</Radio.Button>
|
|
|
|
</Radio.Group>
|
|
|
|
</Form.Item>
|
|
|
|
</Form>
|
|
|
|
<Skeleton.Button active={buttonActive} size={buttonSize} shape={buttonShape} />
|
|
|
|
</div>
|
|
|
|
<br />
|
|
|
|
<div>
|
|
|
|
<Form layout="inline" style={{ marginBottom: 16 }}>
|
|
|
|
<Form.Item label="AvatarActive">
|
|
|
|
<Switch checked={avatarActive} onChange={this.handleActiveChange('avatarActive')} />
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item label="AvatarSize">
|
|
|
|
<Radio.Group value={avatarSize} onChange={this.handleSizeChange('avatarSize')}>
|
|
|
|
<Radio.Button value="default">Default</Radio.Button>
|
|
|
|
<Radio.Button value="large">Large</Radio.Button>
|
|
|
|
<Radio.Button value="small">Small</Radio.Button>
|
|
|
|
</Radio.Group>
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item label="AvatarShape">
|
|
|
|
<Radio.Group value={avatarShape} onChange={this.handleShapeChange('avatarShape')}>
|
|
|
|
<Radio.Button value="square">Square</Radio.Button>
|
|
|
|
<Radio.Button value="circle">Circle</Radio.Button>
|
|
|
|
</Radio.Group>
|
|
|
|
</Form.Item>
|
|
|
|
</Form>
|
|
|
|
<Skeleton.Avatar active={avatarActive} size={avatarSize} shape={avatarShape} />
|
|
|
|
</div>
|
2019-11-21 20:23:56 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(<Demo />, mountNode);
|
|
|
|
```
|