|
@@ -2,8 +2,10 @@
|
|
|
export struct AddAndSubtractComp {
|
|
|
// 输入值
|
|
|
@State inputNum: number = 0
|
|
|
- // 输入值所在的对象(不存在则不传)
|
|
|
- obj: any
|
|
|
+ // 输入值所在的对象用于修改(不存在则不传)
|
|
|
+ obj: Object
|
|
|
+ // 需要修改的对象的属性名
|
|
|
+ editPropertyName: string
|
|
|
// 输入值上限、下限
|
|
|
upperLimit: number
|
|
|
lowerLimit: number
|
|
@@ -51,17 +53,15 @@ export struct AddAndSubtractComp {
|
|
|
// 校验数据有效性
|
|
|
if (this.lowerLimit && num < this.lowerLimit) {
|
|
|
this.inputNum = this.lowerLimit
|
|
|
- this.obj['standardValue'] = this.inputNum
|
|
|
+ this.obj[this.editPropertyName] = this.inputNum
|
|
|
return
|
|
|
} else if (this.upperLimit && num > this.upperLimit) {
|
|
|
this.inputNum = this.upperLimit
|
|
|
- this.obj['standardValue'] = this.inputNum
|
|
|
+ this.obj[this.editPropertyName] = this.inputNum
|
|
|
return
|
|
|
}
|
|
|
this.inputNum = num
|
|
|
- if (this.obj.hasOwnProperty('actualValue')) {
|
|
|
- this.obj['actualValue'] = num
|
|
|
- }
|
|
|
+ this.obj[this.editPropertyName] = this.inputNum
|
|
|
})
|
|
|
}
|
|
|
.width('50%')
|