我对React有点陌生,尝试将className设置为string + prop。但是我不确定该怎么做以及这是否是最佳实践。
所以我正在尝试做的,显然是行不通的,是这样的:
<a data-featherlight='string' + {this.props.data.imageUrl}>
我该如何写呢?
您可以使用字符串串联
<a data-featherlight={'string' + this.props.data.imageUrl}>
或使用Template strings新的ES2015功能
Template strings
<a data-featherlight={ `string${this.props.data.imageUrl}` }>