Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 如何为react创建二维阵列_Reactjs - Fatal编程技术网

Reactjs 如何为react创建二维阵列

Reactjs 如何为react创建二维阵列,reactjs,Reactjs,这是我迄今为止为生成网格中坐标列表的getCoordinates函数编写的代码 getCoordinates = () => { let result = [] for (int i = 1; i <= this.state.gridSize; i++){ for (int j = 1; j <= this.state.gridSize; j++){ result.push([i*100,

这是我迄今为止为生成网格中坐标列表的
getCoordinates
函数编写的代码

getCoordinates = () => {
        let result = []
        for (int i = 1; i <= this.state.gridSize; i++){
            for (int j = 1; j <= this.state.gridSize; j++){
                result.push([i*100, j*100])
            }
        }
        return result;
};

有人能帮我找到正确的语法吗?

这里的问题是变量
i
j
的声明。目前,它们是用Java(或类似)语法声明的。相反,那些
int
关键字应替换为
let

像这样:

getCoordinates=()=>{
让结果=[]
for(让i=1;i?注意,将实际输出作为您的一部分(甚至在发布之前,搜索您的错误消息)是有帮助的。
[[100, 100], [100, 200], [100, 300], [100, 400],
[200, 100], [200, 200], [200, 300], [200, 400],
[300, 100], [300, 200], [300, 300], [300, 400],
[400, 100], [400, 200], [400, 300], [400, 400]]