📌  相关文章
📜  如何在 React js 中获取当前日期 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:14.428000             🧑  作者: Mango

代码示例3
import React from "react";

export default class App extends React.Component {
  state = {
    date: ""
  };

  componentDidMount() {
    this.getDate();
  }

  getDate = () => {
    var date = new Date().toDateString();
    this.setState({ date });
  };

  render() {
    const { date } = this.state;

    return 
{date}
; } } } export default App;