有没有办法在我的Dropdown标签里面给我的title属性加一个值。例如,我想得到title='Lead'+{this.state.candidance}。我也在使用'rsuite'的Dropdown。
<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>
由于{}里面的任何东西都是一个内联的JSX表达式,你可以这样做。
title={"Lead" + this.state.candidate.length}
你也可以使用ES6的字符串插值template 字符与``(回标)和。${expr}
,像这样。
title={`Lead${this.state.candidate.length}`}
希望能帮到你
你需要用托架把你的道具包起来。{} 代号
在括号里你可以写任何javascript代码。
<Dropdown title={'Lead ' + this.state.candidate.length}>
ES6的方式。
<Dropdown title={`Lead${his.state.candidate.length}`}>
title={`Lead${this.state.candidate.length}`}
应该可以了
试试这个。简单的 template string
解决办法。
title={`WhateverYouWantHere`}