Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

杜鹏辉 #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions 1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://unpkg.com/react@15/dist/react.js"></script>
<script src="https://unpkg.com/react-dom@15/dist/react-dom.js"></script>
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
</head>
<body>
<div id="root"></div>
</body>
<!--<script src="node_modules/"></script>-->
<script type="text/babel">
/*
class Hello extends React.Component{
constructor(){
super();
}
render(){
return (<div>{(this.props.children).map(function(a,b){
return <li key={b}>{a}</li>
})}</div>)
// return <div>{this.props.con}</div>
}
}
ReactDOM.render(<Hello><span>span</span><span>em</span><span>i</span></Hello>,document.getElementById("root"));
// ReactDOM.render(<hello con="hello world"/>,document.getElementById("root"));

*/

/*
class Abc extends React.Component{
constructor(){
super();
}
render(){
return (<div>{(this.props.children).map(function(a,b){
return <li key={b}>{a}</li>
})}</div>)
// return <div>{this.props.con}</div>
}
}
ReactDOM.render(<Abc data={arr}/>,document.getElementById("root"));
*/


// 生命周期
class Time extends React.Component{
constructor(){
super();
this.state={time:0}
console.log("构造函数");
}
componentWillMount(){
console.log("组件即将装备到页面中");
}
render(){
console.log("组件正在渲染到页面中")
return <div>{this.state.time}</div>
}
componentDidMount(){
console.log("div已经渲染到页面中");
var num=0;
setInterval(()=>{
console.log(num);
num++;
this.setState({time:num});
},1000)
}
}
ReactDOM.render(<Time/>,document.getElementById("root"));

// var arr=[1,2,3,4]
// arr.map(function (a,b,c) {/* a 每一个 | b下标 | c 操作数组*/
// console.log(a+"--"+b+"--"+c)
// })
</script>

</html>
73 changes: 73 additions & 0 deletions 2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://unpkg.com/react@15/dist/react.js"></script>
<script src="https://unpkg.com/react-dom@15/dist/react-dom.js"></script>
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
</head>
<body>
<div id="root"></div>
</body>
<!--<script src="node_modules/"></script>-->
<script type="text/babel">
class Title extends React.Component{
constructor(){
super();
}
render(){
return <div>{this.props.title}</div>
}
}
class List extends React.Component{
constructor(){
super();
}
render(){
return (
<ul>
{this.props.listdata.map((a,b)=>{
return <li key={b}>{a.con}</li>
})}
</ul>
)
}
}
//单向流->从顶层组件到子组件
class Todo extends React.Component{
constructor(){
super();
this.state={text:"",arr:[]};
}
change(e){
this.state.text=e.target.value;
}
submit(){
var obj={
con:this.state.text
}
this.setState(function (prev) {
return {
arr:prev.arr.concat(obj)
}
})
}
render(){
return (
<div>
<Title title="待办事项"/>
<List listdata={this.state.arr}/>
<input type="text" onChange={this.change.bind(this)}/>
<input type="submit" onClick={this.submit.bind(this)}/>
</div>
)
}
}
ReactDOM.render(<Todo/>,document.getElementById("root"))
</script>

</html>
75 changes: 0 additions & 75 deletions 3.组件的嵌套.html

This file was deleted.

50 changes: 0 additions & 50 deletions 4.生命周期.html

This file was deleted.

49 changes: 0 additions & 49 deletions 5.生命周期.html

This file was deleted.

17 changes: 0 additions & 17 deletions package.json

This file was deleted.

Loading