gpt4 book ai didi

javascript - 意外的 token ,预期的......

转载 作者:行者123 更新时间:2023-12-01 02:00:12 25 4
gpt4 key购买 nike

我在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com