我正在申请。例如,我尝试在以下代码中将字母“ 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++) { returna; } } }; componentDidMount = () => { this.draw(); }; render() { return (); } } export default App;2048 Game With React
{this.draw()}
ageoff.. 7
您应该只给我们一个数组。填充数组,然后返回它,React将渲染组件数组。
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 = () => { let result = []; for (let a = 0; a < 4; a++) { for (let b = 0; b < 4; b++) { result.push(a); } } return result; }; componentDidMount = () => { this.draw(); }; render() { return (); } } export default App;2048 Game With React
{this.draw()}
Code-Apprent.. 5
将 您应该只给我们一个数组。填充数组,然后返回它,React将渲染组件数组。 {this.draw()} 将return
让你只能得到一个中止整个循环
1> ageoff..: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 = () => {
let result = [];
for (let a = 0; a < 4; a++) {
for (let b = 0; b < 4; b++) {
result.push(
2048 Game With React
2> Code-Apprent..:return
让你只能得到一个中止整个循环
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有