[英]Expected an assignment or function call and instead saw an expression error in function
I am having a problem here in React js and it says我在 React js 中遇到问题,它说
Error: Expected an assignment or function call and instead saw an expression错误:需要一个赋值或函数调用,却看到了一个表达式
Error is in this function and here is it:这个函数有错误,错误在这里:
const generateKey = (dataKey) => {
let output = [];
let withKeys;
for (let i = 0; i < dataKey.length; i++){
withKeys = {
...dataKey[i],
key: i,
},
output.push(withKeys);
}
return output;
}
I don't know whats the problem in here.我不知道这里有什么问题。 Thanks in advance for the help
先谢谢您的帮助
The problem is inside the for
loop.问题出在
for
循环内部。 There should be a semicolon instead of comma.应该有一个分号而不是逗号。 Fix it like below:
像下面这样修复它:
for (let i = 0; i < dataKey.length; i++){
withKeys = {
...dataKey[i],
key: i,
};
output.push(withKeys);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.