下面是我的react组件的一部分.我有一个名为daysUntil的props 进入这个包含数字的组件.在本例中,传递数字0会导致fontWeight函数返回700
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;
}
我得到以下错误:
NSNumber类型的JSON值"700"无法转换为NSSTring.
我假设这是因为font weight希望值是字符串格式.这个问题的正确解决方法是什么?
提前谢谢!