0
点赞
收藏
分享

微信扫一扫

react学习笔记(一)

import React from 'react';
import ReactDOM from 'react-dom';
//es6语法
//style内联样式不能用html那种方式,需要用对象写法如style={{"color":'red'}} ,class要写成className,因为class在es6中是关键字
//{}js表达式
class Hello extends React.Component{
constructor(props) {
super(props);
this.state = { opacity:1,
fontSize:'12px' //这种类型要写成驼峰式写法
};
}

render(){


return <div style={{opacity:this.state.opacity,fontSize:this.state.fontSize}} className="dd"> Hello {this.props.name}</div>
}
}
ReactDOM.render(
<Hello name = "react"/>,
document.getElementById('app')
);


举报

相关推荐

0 条评论