Skip to content

Commit

Permalink
add 14
Browse files Browse the repository at this point in the history
  • Loading branch information
HeeBooo committed Oct 5, 2017
1 parent 6965d5c commit 295c775
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test10-style.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
this.setState({
opacity: opacity
})
}.bind(this), 100);
}, 100);
},
render: function () {
return (
Expand Down
2 changes: 1 addition & 1 deletion test11-ajax.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
lastGistUrl: lastGist.html_url
})
}
}.bind(this))
})
},
render: function () {
return (
Expand Down
49 changes: 49 additions & 0 deletions test13-mount.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div id="root"></div>
<script src="./build/react.js"></script>
<script src="./build/react-dom.js"></script>
<script src="./build/browser.min.js"></script>
<script src="./build/jquery.min.js"></script>
<script type="text/babel">
let Hello = React.createClass({
// 初始化
getInitialState: function () {
alert('init');
return {
opacity: 1.0,
fontSize: '12px'
}
},
render: function () {
return <div style={{opacity: this.state.opacity, fontSize: this.state.fontSize}}>Hello {this.props.name}</div>;
},
// 组件渲染前
componentWillMount: function () {
alert('will');
},
// 组件渲染后
componentDidMount: function () {
alert('did');
setTimeout(() => {
console.log(this)
this.setState({
opacity: 0.5,
fontSize: '44px'
})
}, 1000);
}
});
ReactDOM.render(
<Hello name='world' />,
document.getElementById('root')
)
</script>
</body>
</html>
49 changes: 49 additions & 0 deletions test14.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div id="root"></div>
<script src="./build/react.js"></script>
<script src="./build/react-dom.js"></script>
<script src="./build/browser.min.js"></script>
<script src="./build/jquery.min.js"></script>
<script type="text/babel">
let TestClickComponent = React.createClass({
render: function () {
return (
<div>
<button>显示|隐藏</button>
<span>测试点击</span>
</div>
)
}
});
let TestInputComponent = React.createClass({
getInitialState: function () {
return {
inputContent: ''
}
},
render: function () {
return (
<div>
<input type="text" />
<span>{this.state.inputContent}</span>
</div>
)
}
})
ReactDOM.render(
<div>
<TestClickComponent />
<TestInputComponent />
</div>,
document.getElementById('root')
)
</script>
</body>
</html>

0 comments on commit 295c775

Please sign in to comment.