mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-04 04:48:32 +08:00
feat: 评分组件 texts、colors 过滤非数字key, 如:$$id
This commit is contained in:
parent
4f9395fb3b
commit
addbc69fd7
@ -138,9 +138,12 @@ export class Rating extends React.Component<RatingProps, any> {
|
||||
const showKey = keys.filter(item => Number(item) < value).length;
|
||||
|
||||
const showColor = keys[showKey] !== undefined && colors[keys[showKey]];
|
||||
|
||||
// 取最大 key 的颜色,避免如下情况:colors 只设置了 1-4,value 为 5,导致取不到颜色而无法显示
|
||||
const lastColor = keys.length && colors[keys[keys.length - 1]];
|
||||
|
||||
this.setState({
|
||||
showColor: showColor || ''
|
||||
showColor: showColor || lastColor || ''
|
||||
});
|
||||
} else if (colors && typeof colors === 'string') {
|
||||
this.setState({
|
||||
|
Loading…
Reference in New Issue
Block a user