numMapVals: { [key: number]: number } = {} //声明字典 {}必须赋初值,否则就会是undefault
增
/** * 添加一个数值属性 */
AddNumAttr(key: number, val: number): number {
if (uac.AllNumberAttr[key] != undefined || uac.AllNumberAttr[key] != null) {
if (this.numMapVals[key] == undefined || this.numMapVals[key] == null) {
this.numMapVals[key] = 0
}
this.numMapVals[key] += val
if ((uac.Positive[key] != undefined || uac.Positive[key] != null) && (this.numMapVals[key] < 0)) {
this.numMapVals[key] = 0
}
return this.numMapVals[key]
}
return 0
}
/** * 删除一个数值属性 */
网友评论