ant-design/components/rate/demo/text.md

43 lines
707 B
Markdown
Raw Normal View History

2016-04-01 10:12:02 +08:00
---
order: 2
title:
zh-CN: 文案展现
en-US: Show copywriting
2016-04-01 10:12:02 +08:00
---
2016-03-31 14:43:38 +08:00
## zh-CN
2016-03-31 14:43:38 +08:00
给评分组件加上文案展示。
## en-US
Add copywriting in rate components.
2017-02-13 10:55:53 +08:00
````jsx
2016-03-31 14:43:38 +08:00
import { Rate } from 'antd';
2018-12-28 16:04:05 +08:00
const desc = ['terrible', 'bad', 'normal', 'good', 'wonderful'];
class Rater extends React.Component {
state = {
value: 3,
}
2018-06-27 15:55:04 +08:00
handleChange = (value) => {
2016-03-31 14:43:38 +08:00
this.setState({ value });
}
2018-06-27 15:55:04 +08:00
2016-03-31 14:43:38 +08:00
render() {
const { value } = this.state;
return (
<span>
2018-12-28 16:04:05 +08:00
<Rate tooltips={desc} onChange={this.handleChange} value={value} />
{value ? <span className="ant-rate-text">{desc[value - 1]}</span> : ''}
2016-03-31 14:43:38 +08:00
</span>
);
}
}
2016-03-31 14:43:38 +08:00
ReactDOM.render(<Rater />, mountNode);
````