Javascript 为什么我会收到 SyntaxError: Assigning to rvalue?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36876712/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 19:40:08  来源:igfitidea点击:

Why do I get SyntaxError: Assigning to rvalue?

javascriptmeteorreactjs

提问by Vlad Stan

I have a map()and I want to pass two parameters:

我有一个map(),我想传递两个参数:

  1. a string
  2. a function
  1. 一个字符串
  2. 一个函数

Example code:

示例代码:

{
  values.map((workflow, totalWorkflow()) => {
    return <WorkflowSingle key={ workflow } workflow={ workflow } />
  })
}

Why do I get this error: SyntaxError: Assigning to rvalue

为什么我会收到此错误: SyntaxError: Assigning to rvalue

采纳答案by isvforall

If your mapfunction is the Array.prototype.mapfunction, you passed wrong parameters to the function, mapaccepts callback and second optional parameter, like this:

如果您的map函数是Array.prototype.map函数,则您向函数传递了错误的参数,map接受回调和第二个可选参数,如下所示:

arr.map(callback[, thisArg])

arr.map(回调[, thisArg])

For your case:

对于您的情况:

values.map(function(x) {
    return <WorkflowSingle key = { x.workflow } workflow = { x.workflow } />
});  

回答by Ignatius Andrew

You get rvalueerror, when you use =instead of ==in a condition checking block.

rvalue当您在条件检查块中使用=而不是使用时,您会收到错误==