有没有办法在下拉标签中添加一个值到我的title属性。例如,我想得到标题=‘铅’+ {this.state.candidate.length}。我也使用了从'rsuite‘下拉。
<Sidenav className="nav1-full" defaultOpenKeys={['1']} activeKey="1">
<Sidenav.Body>
<Nav className="nav-bar">
<Dropdown className="nav1-body" eventKey="1" title="Lead">
<Dropdown.Item eventKey="1-1" href="/candidates/1">
Exploratory
</Dropdown.Item>
<Dropdown.Item eventKey="1-2" href="/candidates/2">
Phone Intro
</Dropdown.Item>
</Dropdown>
</Nav>
</Sidenav.Body>
</Sidenav>发布于 2020-04-22 20:53:05
由于{}中的任何内容都是内联的JSX表达式,所以可以这样做:
title={"Lead" + this.state.candidate.length}您还可以将ES6字符串内插/模板文字与 (backticks)和${expr}一起使用,如下所示:
title={`Lead${this.state.candidate.length}`}希望能帮上忙。
发布于 2020-04-22 20:52:40
你需要用括号{}来包装你的道具,而不是用引号。
在括号中,您可以编写任何javascript代码:
<Dropdown title={'Lead ' + this.state.candidate.length}>ES6方式:
<Dropdown title={`Lead${his.state.candidate.length}`}>发布于 2020-04-22 20:46:51
title={`Lead${this.state.candidate.length}`}应该做点什么
https://stackoverflow.com/questions/61374710
复制相似问题