In javascript I'm defining some in-line stylings, one of them is font-weight. Unfortunately it doesn't work as automatically 'px' is added at the end of the value and then it doesn't get rendered as the value is not correct :
Note: I'm using react , therefore the code looks like the following.
render: function() {
return (
<table>
<tbody>
<tr>
{
data.map(function(d, i) {
var style = {};
if (d.value === 'selected') {
style['color'] = '#FFFFFF';
style['font-size'] = '16px';
style['font-style'] = 'normal';
style['font-weight'] = '700';
style['text-transform'] = 'uppercase';
}else {
style['border'] = '2px solid #C9C9C9';
style['color'] = '#C9C9C9';
style['font-size'] = '12px';
style['font-style'] = 'normal';
style['font-weight'] = '400';
}
return (<td>
<div style={style}>
{d.value}
</div>
</td>);
})
}
</tr>
</tbody>
</table>
);
}
When I inspect it in chrome, it shows : font-weight: 700px
and it doesn't work as px
makes the value incorrect.
根据此处的反应文档,尝试使用style['fontWeight']
代替style['font-weight']
,fontWeight属性不会获得自动的'px'后缀。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.