我在 react 中遇到以下错误
Unexpected token, expected ... (16:6)
return (
15 | <div className={classes.BuildControls}
16 | { controls.map(el =>(<BuildControl key={el.label} label={el.label} />))}
| ^
17 | </div>
18 | )
19 | };
这是我的代码
import React from 'react';
import Classes from './build-controls.css';
import BuildControl from './build-control-r/build-control.js';
const controls = [
{ label: "Salad", type:"salad" },
{ label: "Cheese", type:"cheese" },
{ label: "Meat", type:"meat" },
{ label: "bacon", type:"bacon" }
]
const buildControls = (props) => {
return (
<div className={classes.BuildControls}
{ controls.map(el =>(<BuildControl key={el.label} label={el.label} />))}
</div>
)
};
export default buildControls;
[问题]:有人可以告诉我我做错了什么吗?如果我还需要分享其他内容,请告诉我
最佳答案
请关闭元素
const buildControls = (props) => {
return (
<div className={classes.BuildControls}> // Need to close bracket
{ controls.map(el =>(<BuildControl key={el.label} label={el.label} />))}
</div>
)
};
关于javascript - 意外的 token ,预期的......,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50658043/