简体   繁体   English

期望赋值或函数调用,但在函数中看到表达式错误

[英]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.

相关问题 期望赋值或函数调用,而是看到了一个表达式 - Expected an assignment or function call and instead saw an expression 期望一个赋值或函数调用,而是看到一个表达式? - Expected an assignment or function call and instead saw an expression? 期望一个赋值或函数调用,而是看到一个表达式 - Expected an assignment or function call and instead saw an expression 错误-预期分配或函数调用,而是看到一个表达式 - Error - Expected an assignment or function call and instead saw an expression ReactJS错误:“预期分配或函数调用,而是看到了一个表达式” - ReactJS error: “Expected an assignment or function call and instead saw an expression” 错误:预期分配或函数调用,而是看到一个表达式 - Error: expected an assignment or function call and instead saw an expression 反应错误 [期望赋值或函数调用,而是看到一个表达式] - React error [Expected an assignment or function call and instead saw an expression] 语法错误(预期分配或函数调用,而是看到一个表达式) - Syntax Error (Expected an assignment or function call and instead saw an expression) 错误预期分配或函数调用,而是看到一个表达式 - Error-Expected an assignment or function call and instead saw an expression Eslint 错误:'预期分配或 function 调用,而是看到一个表达式' - Eslint Error: 'Expected an assignment or function call and instead saw an expression'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM