1 Star 0 Fork 0

Hanley / study-front

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
36th.html 1.17 KB
一键复制 编辑 原始数据 按行查看 历史
hanley 提交于 2018-07-25 22:22 . react component lifecycle
<!DOCTYPE html>
<html>
<head>
<title>react-组件</title>
<meta charset="UTF-8" />
<script src='../node_modules/react/umd/react.development.js'></script>
<script src='../node_modules/react-dom/umd/react-dom.development.js'></script>
<script src='../node_modules/babel-standalone/babel.min.js'></script>
</head>
<body>
<div id="my"></div>
<script type="text/babel">
var data = {
name:'lily',
age:18
};
/*1、使用函数定义一个组件 需要显示传递props */
function Welcome(props){
var name1='abc';
return <div >Welcome,{props.msg} {name1}</div>
}
/*2、使用ES6来定义一个类的名称 定义组件*/
class Hello extends React.Component{
render(){
return <div>Hello,abc,{this.props.age}</div>
}
};
function App(){
return (
<div>
<Welcome msg={data.name}></Welcome>
<Welcome msg='xyz'></Welcome>
<Hello age={data.age}></Hello>
<Hello age='100'></Hello>
</div>
)
};
ReactDOM.render(
<App />,
document.getElementById('my')
)
</script>
</body>
</html>
1
https://gitee.com/thanlin/study.git
git@gitee.com:thanlin/study.git
thanlin
study
study-front
master

搜索帮助