diff --git a/src/rate/README.md b/src/rate/README.md index 4e63a5d38..24adf9d1c 100644 --- a/src/rate/README.md +++ b/src/rate/README.md @@ -119,6 +119,7 @@ export default { | disabled-color | Disabled color | *string* | `#bdbdbd` | | icon | Selected icon | *string* | `star` | | void-icon | Void icon | *string* | `star-o` | +| icon-prefix `v2.5.3` | Icon className prefix | *string* | `van-icon` | | allow-half | Whether to allow half star | *boolean* | `false` | | readonly | Whether to be readonly | *boolean* | `false` | | disabled | Whether to disable rate | *boolean* | `false` | diff --git a/src/rate/README.zh-CN.md b/src/rate/README.zh-CN.md index fc7f0c9fa..73d5828b3 100644 --- a/src/rate/README.zh-CN.md +++ b/src/rate/README.zh-CN.md @@ -118,7 +118,8 @@ export default { | void-color | 未选中时的颜色 | *string* | `#c8c9cc` | | disabled-color | 禁用时的颜色 | *string* | `#bdbdbd` | | icon | 选中时的[图标名称](#/zh-CN/icon)或图片链接 | *string* | `star` | -| void-icon | 未选中时的[图标名称](#/zh-CN/icon)或图片链接 | *string* | `star-o` | +| void-icon | 未选中时的[图标名称](#/zh-CN/icon)或图片链接 | *string* | `star-o` | +| icon-prefix `v2.5.3` | 图标类名前缀,同 Icon 组件的 [class-prefix 属性](#/zh-CN/icon#props) | *string* | `van-icon` | | allow-half | 是否允许半选 | *boolean* | `false` | | readonly | 是否为只读状态 | *boolean* | `false` | | disabled | 是否禁用评分 | *boolean* | `false` | diff --git a/src/rate/index.js b/src/rate/index.js index a0ae252ba..b257d5b8e 100644 --- a/src/rate/index.js +++ b/src/rate/index.js @@ -34,6 +34,7 @@ export default createComponent({ disabled: Boolean, allowHalf: Boolean, voidColor: String, + iconPrefix: String, disabledColor: String, value: { type: Number, @@ -173,8 +174,9 @@ export default createComponent({ size={this.sizeWithUnit} name={isFull ? icon : voidIcon} class={bem('icon', { disabled, full: isFull })} - data-score={score} color={disabled ? disabledColor : isFull ? color : voidColor} + classPrefix={this.iconPrefix} + data-score={score} onClick={() => { this.select(score); }} @@ -184,8 +186,9 @@ export default createComponent({ size={this.sizeWithUnit} name={isVoid ? voidIcon : icon} class={bem('icon', ['half', { disabled, full: !isVoid }])} - data-score={score - 0.5} color={disabled ? disabledColor : isVoid ? voidColor : color} + classPrefix={this.iconPrefix} + data-score={score - 0.5} onClick={() => { this.select(score - 0.5); }}