您的位置:首页 > 科技 > IT业 > java源码网_电影网页设计模板图片_外链代发_搜索推广和信息流推广的区别

java源码网_电影网页设计模板图片_外链代发_搜索推广和信息流推广的区别

2024/10/31 17:32:24 来源:https://blog.csdn.net/weixin_41987016/article/details/143252160  浏览:    关键词:java源码网_电影网页设计模板图片_外链代发_搜索推广和信息流推广的区别
java源码网_电影网页设计模板图片_外链代发_搜索推广和信息流推广的区别
nvm -v
nvm install 16.20.2
nvm use 16.20.2
nvm install -g create-react-app
create-react-app redux_test

  • public/index.html
<!DOCTYPE html>
<html><head><meta charset="UTF-8"><title>redux</title></head><body><div id="root"></div></body>
</html>
  • src/App.jsx
import React, {Component} from 'react';
import Count from "./components/Count";class App extends Component {render() {return (<div><Count/></div>);}
}export default App;
  • src/index.js 入口文件
import React from "react";
import ReactDOM from 'react-dom'
import App from './App'ReactDOM.render(<App/>,document.getElementById('root'))
  • src/components/Count/index.jsx
import React, {Component} from 'react';class Count extends Component {state = {count:0}// 加法increment=()=>{const {value} = this.selectNumberconst {count} = this.statethis.setState({count:count+value*1})}// 减法decrement=()=>{const {value} = this.selectNumberconst {count} = this.statethis.setState({count:count-value*1})}// 奇数再加incrementIfOdd=()=>{const {value} = this.selectNumberconst {count} = this.stateif(count % 2 !== 0) {this.setState({count:count+value*1})}}// 异步加incrementAsync=()=>{const {value} = this.selectNumberconst {count} = this.statesetTimeout(()=>{this.setState({count:count+value*1})},500)}render() {return (<div><h1>当前求和为:{this.state.count}</h1><select ref={c => this.selectNumber = c}><option value="1">1</option><option value="2">2</option><option value="3">3</option></select>&nbsp;<button onClick={this.increment}>+</button>&nbsp;<button onClick={this.decrement}>-</button>&nbsp;<button onClick={this.incrementIfOdd}>当前求和为奇数再加</button>&nbsp;<button onClick={this.incrementAsync}>异步加</button>&nbsp;</div>);}
}export default Count;

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com