小编fur*_*sen的帖子

是否可以在React中打印16次

我正在申请。例如,我尝试在以下代码中将字母“ a”打印16次。但这没有用。这是因为我确实使用“返回”。我知道。但是它不使用错误。如何打印字母“ a” 16次?

import React from "react";
import Game from "./game";

class App extends React.Component {
  constructor(props) {
    super(props);
    this.Game = new Game();
    console.log(this.Game.play());
  }
  draw = () => {
    for (let a = 0; a < 4; a++) {
      for (let b = 0; b < 4; b++) {
        return <div>a</div>;
      }
    }
  };
  componentDidMount = () => {
    this.draw();
  };
  render() {
    return (
      <div>
        <h2>2048 Game With React</h2>
        <p>{this.draw()}</p>
      </div>
    );
  }
}

export default App;

Run Code Online (Sandbox Code Playgroud)

javascript arrays reactjs react-router react-native

5
推荐指数
2
解决办法
121
查看次数

标签 统计

arrays ×1

javascript ×1

react-native ×1

react-router ×1

reactjs ×1