您的位置:首页 > Web前端 > React

React学习笔记:设置行内样式style属性

2017-08-10 15:17 429 查看
在react中,可以这样来设置行内样式:

render() {
const styles = {color:"red",fontSize:"16px"};
return (
<div style={styles}></div>
);
}

注意
styles
是一个json对象,key对应css属性名并且转为驼峰式命名。

更加便捷的写法:

render() {
return (
<div style={{color:"red",fontSize:"16px"}}></div>
);
}

参考:https://react-cn.github.io/react/tips/inline-styles.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: