<a href={ routeName }>{ label}</a>
引用:React not passing along properties when rendering in variable
我已经尝试过
<a href={# routeName }>{ label}</a>
<a href=#{ routeName }>{ label}</a>
两者都给出错误。
最佳答案
试试这个
<a href={ ('#' + this.props.routeName) }>{ this.props.routeName }</a>;
你也可以省略()
<a href={ '#' + this.props.routeName }>{ this.props.routeName }</a>
关于javascript - 如何为 href 属性添加哈希符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32885721/