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
Why do I get SyntaxError: Assigning to rvalue?
提问by Vlad Stan
I have a map()
and I want to pass two parameters:
我有一个map()
,我想传递两个参数:
- a string
- a function
- 一个字符串
- 一个函数
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 map
function is the Array.prototype.map
function, you passed wrong parameters to the function, map
accepts 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 rvalue
error, when you use =
instead of ==
in a condition checking block.
rvalue
当您在条件检查块中使用=
而不是使用时,您会收到错误==
。