ant-design/components/input-number/demo/disabled.md

46 lines
732 B
Markdown
Raw Normal View History

2016-03-31 09:40:55 +08:00
---
order: 2
2016-08-18 15:59:07 +08:00
title:
2019-05-07 14:57:32 +08:00
zh-CN: 不可用
en-US: Disabled
2016-03-31 09:40:55 +08:00
---
2015-07-15 16:13:00 +08:00
2016-08-18 15:59:07 +08:00
## zh-CN
点击按钮切换可用状态。
## en-US
Click the button to toggle between available and disabled states.
2015-07-15 16:13:00 +08:00
2019-05-07 14:57:32 +08:00
```jsx
import { InputNumber, Button } from 'antd';
2015-07-15 16:13:00 +08:00
class App extends React.Component {
state = {
disabled: true,
};
2018-06-27 15:55:04 +08:00
toggle = () => {
2015-07-15 16:13:00 +08:00
this.setState({
2016-05-11 09:32:33 +08:00
disabled: !this.state.disabled,
2015-07-15 16:13:00 +08:00
});
2019-05-07 14:57:32 +08:00
};
2018-06-27 15:55:04 +08:00
2015-07-15 16:13:00 +08:00
render() {
return (
<>
<InputNumber min={1} max={10} disabled={this.state.disabled} defaultValue={3} />
<div style={{ marginTop: 20 }}>
2019-05-07 14:57:32 +08:00
<Button onClick={this.toggle} type="primary">
Toggle disabled
</Button>
</div>
</>
);
}
}
2015-07-15 16:13:00 +08:00
export default App;
2019-05-07 14:57:32 +08:00
```