[LayaAir 2.0]设置fontSize的时候没做类型转换
__getset(0,__proto,'fontSize',function(){
return this._fontSize;
},function(value){
if (this._fontSize !=value){
this._fontSize=value;
this.isChanged=true;
}
});
如果设置fontSize="30",没有做类型转换,后面所有通过fontSize参与的加法运算都会变成字符串拼接运算。建议加上parseInt转换。
其他给fontSize赋值的都加上了转换,差这里没加。
this.fontSize=parseInt(tInfo[0].getAttributeNode("size").nodeValue);
this.fontSize=parseInt(tInfo[0].attributes["size"].nodeValue);
return this._fontSize;
},function(value){
if (this._fontSize !=value){
this._fontSize=value;
this.isChanged=true;
}
});
如果设置fontSize="30",没有做类型转换,后面所有通过fontSize参与的加法运算都会变成字符串拼接运算。建议加上parseInt转换。
其他给fontSize赋值的都加上了转换,差这里没加。
this.fontSize=parseInt(tInfo[0].getAttributeNode("size").nodeValue);
this.fontSize=parseInt(tInfo[0].attributes["size"].nodeValue);
1 个回复
Aar0n
赞同来自: