React学习案例十三

Posted hhh江月

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了React学习案例十三相关的知识,希望对你有一定的参考价值。

React学习案例十三

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Hello React!</title>
<script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script>
<script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script>
<script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
</head>
<body>

<div id="example"></div>
<script type="text/babel">
class Clock extends React.Component 
  constructor(props) 
    super(props);
    this.state = date: new Date();
  

  componentDidMount() 
    this.timerID = setInterval(
      () => this.tick(),
      1000
    );
  

  componentWillUnmount() 
    clearInterval(this.timerID);
  

  tick() 
    this.setState(
      date: new Date()
    );
  

  render() 
    return (
      <div>
        <h1>Hello, world!</h1>
        <h2>现在是 this.state.date.toLocaleTimeString().</h2>
      </div>
    );
  


ReactDOM.render(
  <Clock />,
  document.getElementById('example')
);
</script>

</body>
</html>




<!-- <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Hello React!</title>
<script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script>
<script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script>
<script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
</head>
<body>

<div id="example"></div>
<script type="text/babel">
class Clock extends React.Component 
  constructor(props) 
    super(props);
    this.state = date: new Date();
  

  componentDidMount() 
    this.timerID = setInterval(
      () => this.tick(),
      1000
    );
  

  componentWillUnmount() 
    clearInterval(this.timerID);
  

  tick() 
    this.setState(
      date: new Date()
    );
  

  render() 
    return (
      <div>
        <h1>Hello, world!</h1>
        <h2>现在是 this.state.date.toLocaleTimeString().</h2>
      </div>
    );
  


ReactDOM.render(
  <Clock />,
  document.getElementById('example')
);
</script>

</body>
</html> -->

<!-- <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Hello React!</title>
<script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script>
<script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script>
<script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
</head>
<body>

<div id="example"></div>
<script type="text/babel">
class Clock extends React.Component 
  constructor(props) 
    super(props);
    this.state = date: new Date();
  

  componentDidMount() 
    this.timerID = setInterval(
      () => this.tick(),
      1000
    );
  

  componentWillUnmount() 
    clearInterval(this.timerID);
  

  tick() 
    this.setState(
      date: new Date()
    );
  

  render() 
    return (
      <div>
        <h1>Hello, world!</h1>
        <h2>现在是 this.state.date.toLocaleTimeString().</h2>
      </div>
    );
  


ReactDOM.render(
  <Clock />,
  document.getElementById('example')
);
</script>

</body>
</html> -->



<!-- <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Hello React!</title>
<script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script>
<script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script>
<script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
</head>
<body>

<div id="example"></div>
<script type="text/babel">
class Clock extends React.Component 
  constructor(props) 
    super(props);
    this.state = date: new Date();
  

  componentDidMount() 
    this.timerID = setInterval(
      () => this.tick(),
      1000
    );
  

  componentWillUnmount() 
    clearInterval(this.timerID);
  

  tick() 
    this.setState(
      date: new Date()
    );
  

  render() 
    return (
      <div>
        <h1>Hello, world!</h1>
        <h2>现在是 this.state.date.toLocaleTimeString().</h2>
      </div>
    );
  


ReactDOM.render(
  <Clock />,
  document.getElementById('example')
);
</script>

</body>
</html> -->

以上是关于React学习案例十三的主要内容,如果未能解决你的问题,请参考以下文章

机器学习实战应用案例100篇(二十三)-粒子群算法从原理到实战应用案例

React 入门学习(十三)-- antd 组件库的基本使用

React 入门学习(十三)-- antd 组件库的基本使用

记账本开发记录——第十三天(2020.1.31)

Python爬虫(二十三)_selenium案例:动态模拟页面点击

Python爬虫(二十三)_selenium案例:动态模拟页面点击