gpt4 book ai didi

javascript - 预期语法错误 : Unexpected token, ,

转载 作者:行者123 更新时间:2023-11-28 17:32:46 25 4
gpt4 key购买 nike

我在 react 中收到此语法错误:

Unexpected token, expected , (22:4)

20 | </div>
21 | </div>
> 22 | )}
| ^
23 | </section>
24 | );
25 | }

我多次查看了每个标签和括号,看看是否都有开始和结束标签/括号,但我似乎找不到错误。可能是其他原因,但我的 javascript 能力不够好,无法发现错误。

我也不明白错误消息,它说“预期”到底是什么意思?

这是错误消息引用的代码:

import React, { Component } from 'react';
import dropdownlist from './dropdowndata';

class Links extends Component {
render() {
return (
<section>
{ dropdownlist.map(drop =>(
<div className="dropdown">
<button className="dropdownhover"> {drop.name} </button>
<div className="links">

drop.button.map(button => (
<div className="linkssection">
<h2> {button.title} </h2>
<ul><li><a className="singlelink" href={button.url}>{button.urlText}</a></li></ul>
</div>
))

</div>
</div>
)}
</section>
);
}
}

export default Links;

提前致谢! :)

最佳答案

关闭第一个 map 功能。

import React, { Component } from 'react';
import dropdownlist from './dropdowndata';

class Links extends Component {
render() {
return (
<section>
{ dropdownlist.map(drop =>(
<div className="dropdown">
<button className="dropdownhover"> {drop.name} </button>
<div className="links">

drop.button.map(button => (
<div className="linkssection">
<h2> {button.title} </h2>
<ul><li><a className="singlelink" href={button.url}>{button.urlText}</a></li></ul>
</div>
))

</div>
</div>
))}
</section>
);
}
}

export default Links;

关于javascript - 预期语法错误 : Unexpected token, ,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49909343/

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