[英]Pixel is added to inline font-weight
在javascript中,我定義了一些嵌入式樣式,其中之一是font-weight。 不幸的是,它不能正常工作,因為會自動在值的末尾添加“ px”,然后由於值不正確而無法呈現:
注意:我正在使用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>
);
}
當我在chrome中檢查它時,它顯示: font-weight: 700px
並且由於px
使值不正確而無法使用。
根據此處的反應文檔,嘗試使用style['fontWeight']
代替style['font-weight']
,fontWeight屬性不會獲得自動的'px'后綴。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.