[英]Pixel is added to inline font-weight
In javascript I'm defining some in-line stylings, one of them is font-weight. 在javascript中,我定义了一些嵌入式样式,其中之一是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 : 不幸的是,它不能正常工作,因为会自动在值的末尾添加“ px”,然后由于值不正确而无法呈现:
Note: I'm using react , therefore the code looks like the following. 注意:我正在使用react,因此代码如下所示。
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. 当我在chrome中检查它时,它显示: font-weight: 700px
并且由于px
使值不正确而无法使用。
根据此处的反应文档,尝试使用style['fontWeight']
代替style['font-weight']
,fontWeight属性不会获得自动的'px'后缀。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.