gpt4 book ai didi

reactjs - React - 意外的 token ,预期的 }

转载 作者:行者123 更新时间:2023-12-03 14:19:16 26 4
gpt4 key购买 nike

import React, { Component } from "react"
import { Navbar,NavItem,Nav,Button } from "react-bootstrap"

class NavbarMain extends Component {
constructor(){
this.state={isLoggedIn:false,logInName:null}
}
render(){
let button = null;
let label = null;
if(this.state.isLoggedIn){
button = (<NavItem><Button>Log Out</Button></NavItem>);
label = (<NavItem>Logged in as: {this.state.logInName}<NavItem>);
}else{
button = (<NavItem><Button>Log In</Button></NavItem>);
label = (<NavItem>Not logged in</NavItem>);
}
return(
<Navbar>
<Navbar.Brand>
<p>Web app</p>
</Navbar.Brand>
<Nav pullRight>
{Label}
{Button}
</Nav>
</Navbar>
)
}
}

导出默认NavbarMain

我正在尝试使用react和react-bootstrap创建一个网络应用程序,并使用此代码作为页面顶部显示的导航栏。我收到以下错误

Syntax error: C:/Users/Levi/Desktop/lootbox_simulator/lootbox-simulator/src/Components/NavbarMain.js: Unexpected token, expected } (15:63)

13 | label = (<NavItem>Logged in as: {this.state.logInName}<NavItem>);
14 | }else{
> 15 | button = (<NavItem><Button>Log In</Button></NavItem>);
| ^
16 | label = (<NavItem>Not logged in</NavItem>);
17 | }
18 | return(

为什么?

最佳答案

这一行是错误的

<NavItem>Logged in as: {this.state.logInName}<NavItem>

应该是

<NavItem>Logged in as: {this.state.logInName}</NavItem>

关于reactjs - React - 意外的 token ,预期的 },我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48245824/

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