Commit df55fcf 1 parent f90a747 commit df55fcf Copy full SHA for df55fcf
File tree 4 files changed +18
-5
lines changed
4 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -17,5 +17,18 @@ Rating component display grade tips when you set `showGrade` attribute.
17
17
```` jsx
18
18
import { Rating } from ' @alifd/next' ;
19
19
20
- ReactDOM .render (< Rating defaultValue= {2 } showGrade / > , mountNode);
20
+ const starMap = {
21
+ 1 : ' Bad' ,
22
+ 2 : ' OK' ,
23
+ 3 : ' Good' ,
24
+ 4 : ' Great' ,
25
+ 5 : ' Perfect'
26
+ };
27
+
28
+ ReactDOM .render (
29
+ < Rating
30
+ defaultValue= {2 }
31
+ showGrade
32
+ readAs= {(val ) => starMap[val]}
33
+ / > , mountNode);
21
34
````
Original file line number Diff line number Diff line change @@ -26,4 +26,4 @@ Rating component is usually used for customer feedback.
26
26
| onChange | callback function on click star<br ><br >** signatures** :<br >Function(value: String) => void<br >** params** :<br >_ value_ : {String} score | Function | func.noop |
27
27
| onHoverChange | callback function on hover star<br ><br >** signatures** :<br >Function(value: String) => void<br >** params** :<br >_ value_ : {String} score | Function | func.noop |
28
28
| disabled | disabled rate or not | Boolean | false |
29
- | readAs | make sense when you set id and enable accessibility <br ><br >** signatures** :<br >Function() => void | Function | val => val |
29
+ | readAs | custom display of grade <br ><br >** signatures** :<br >Function() => void | Function | val => val |
Original file line number Diff line number Diff line change 26
26
| onChange | 用户点击评分时触发的回调<br ><br >** 签名** :<br >Function(value: String) => void<br >** 参数** :<br >_ value_ : {String} 评分值 | Function | func.noop |
27
27
| onHoverChange | 用户hover评分时触发的回调<br ><br >** 签名** :<br >Function(value: String) => void<br >** 参数** :<br >_ value_ : {String} 评分值 | Function | func.noop |
28
28
| disabled | 是否禁用 | Boolean | false |
29
- | readAs | 传入id支持无障碍时,参数才有意义 <br ><br >** 签名** :<br >Function() => void | Function | val => val |
29
+ | readAs | 评分文案生成方法, 传入id支持无障碍时,读屏软件可读 <br ><br >** 签名** :<br >Function() => void | Function | val => val |
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ export default class Rating extends Component {
58
58
*/
59
59
disabled : PropTypes . bool ,
60
60
/**
61
- * 传入id支持无障碍时,参数才有意义
61
+ * 评分文案生成方法, 传入id支持无障碍时,读屏软件可读
62
62
*/
63
63
readAs : PropTypes . func ,
64
64
// 实验属性: 自定义评分icon
@@ -374,7 +374,7 @@ export default class Rating extends Component {
374
374
</ div >
375
375
</ div >
376
376
{
377
- showGrade ? < div className = { `${ prefix } rating-info` } style = { infoStyle } > { value } </ div > : null
377
+ showGrade ? < div className = { `${ prefix } rating-info` } style = { infoStyle } > { readAs ( value ) } </ div > : null
378
378
}
379
379
</ div >
380
380
) ;
You can’t perform that action at this time.
0 commit comments