以下是我反应组件的一部分。我有一个名为daysUntil的道具进入这个包含一个数字的组件。在这个例子中它正在通过其导致fontWeight设置功能中的号码0返回700React Native - NSNumber不能转换为NSString
render: function() {
return (
<Text style={this.style()}>
{this.props.day}
</Text>
)
},
style: function() {
return {
fontWeight: this.fontWeight()
}
},
fontWeight: function() {
var weight = 7 - this.props.daysUntil;
return weight * 100;
}
我得到以下错误:
JSON value '700' of type NSNumber cannot be converted to NSSTring.
我假设这是因为字体重量预计值为字符串格式。什么是适当的解决这个?
预先感谢您!