1
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
Component({
|
||||
properties: {
|
||||
/** 评分 0-10,内部转换为 0-5 星 */
|
||||
/** 评分 0-10,内部转换为 0-5 星,支持半星 */
|
||||
score: {
|
||||
type: Number,
|
||||
value: 0,
|
||||
@@ -19,7 +19,7 @@ Component({
|
||||
|
||||
observers: {
|
||||
score(val: number) {
|
||||
// score(0-10) → star(0-5)
|
||||
// score(0-10) → star(0-5),支持半星(如 7.5 → 3.75星)
|
||||
const clamped = Math.max(0, Math.min(10, val))
|
||||
this.setData({ starValue: clamped / 2 })
|
||||
},
|
||||
|
||||
@@ -3,5 +3,7 @@
|
||||
count="{{5}}"
|
||||
allow-half
|
||||
size="{{size}}"
|
||||
color="#fbbf24"
|
||||
gap="{{4}}"
|
||||
disabled="{{readonly}}"
|
||||
/>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* 星星评分组件样式 */
|
||||
:host {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user