反应如何调用函数内的元素

时间:2018-12-18 06:04:40

标签: javascript reactjs

  import React, { Component } from "react";
import "./App.css";
import Tables from "../src/components/Tables";

const uuidv4 = () =>
  ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
    (
      c ^
      (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))
    ).toString(16)
  );

const CreateTimeTable = (title, rows) => {
  title.map(_title => ({
    title: _title,
    id: uuidv4(),
    data: Array.from({ length: rows }).map(_rows => ({
      id: uuidv4(),
      container: " "
    }))
  }));
};

class App extends Component {
  state = {
    days: CreateTimeTable([
      "Monday",
      "Tuesday",
      "Wednesday",
      "Thursday",
      "Friday",
      "Saturday",
      "Sunday"
    ])
  };

  render() {
    return (
      <div className="App">
        <h1>{this.state.days.title[1]}</h1>
      </div>
    );
  }
}

export default App;

如何在div元素内的函数“ CreateTimeTable”中调用该元素。

刚开始反应希望我能得到一些帮助! 谢谢!

我不断收到错误,例如财产未定义

0 个答案:

没有答案