gpt4 book ai didi

JavaScript chrome 控制台错误

转载 作者:行者123 更新时间:2023-11-28 04:07:04 25 4
gpt4 key购买 nike

在使用 chrome 控制台查看我的代码时,我看到了此错误:

Uncaught ReferenceError :作业第 99 行左侧无效

但我不明白这里出了什么问题

function drawMatrix(matrix, offset) {
matrix.forEach((row, y) => { //THATS LINE 99
row.forEach((value, x) => { //OF COURSE THATS LINE 100
if (value !== 0) {
context.fillStyle = colors[value];
context.strokeStyle = "#dee5e3";
context.lineWidth = 0.1;
context.strokeRect(x + offset.x, y + offset.y , 1, 1);
context.fillRect(x + offset.x,
y + offset.y,
1, 1);
}
});
});}

我很确定即使在第 100 行也一定有错误,可能与 => 有关,但我不明白是什么类型的错误。你能帮助我吗?

最佳答案

错误显示“赋值的左侧”,因此请查找可能错误的“赋值”,例如 var a = b,并且 a 不存在于该作用域或类似的内容中。

因此,正如 @epascarello 所说,控制台中的行号可能不匹配。

关于JavaScript chrome 控制台错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46606852/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com