Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 在JSX中,如何将类名设置为string+;{prop}_Reactjs - Fatal编程技术网

Reactjs 在JSX中,如何将类名设置为string+;{prop}

Reactjs 在JSX中,如何将类名设置为string+;{prop},reactjs,Reactjs,我还不太熟悉如何反应,并尝试将类名设置为string+prop。但我不知道怎么做,也不知道这是否是最好的做法 所以我想做的是,这显然不起作用,是这样的: <a data-featherlight='string' + {this.props.data.imageUrl}> 我该怎么写呢?您可以使用字符串连接 <a data-featherlight={'string' + this.props.data.imageUrl}> 可以使用字符串连接 <a dat

我还不太熟悉如何反应,并尝试将类名设置为string+prop。但我不知道怎么做,也不知道这是否是最好的做法

所以我想做的是,这显然不起作用,是这样的:

<a data-featherlight='string' + {this.props.data.imageUrl}>


我该怎么写呢?

您可以使用字符串连接

<a data-featherlight={'string' + this.props.data.imageUrl}>

可以使用字符串连接

<a data-featherlight={'string' + this.props.data.imageUrl}>

您也可以试试:

<a data-featherlight={'string1' + this.props.data.imageUrl + 'string2'}>
<Link to={`getting-started/${this.props.message}`}>
     <h1>Under {this.props.message}/-</h1>
</Link>


如果您使用的是链接组件,那么您可以像这样连接:

<a data-featherlight={'string1' + this.props.data.imageUrl + 'string2'}>
<Link to={`getting-started/${this.props.message}`}>
     <h1>Under {this.props.message}/-</h1>
</Link>

在{this.props.message}下/-

您也可以试试:

<a data-featherlight={'string1' + this.props.data.imageUrl + 'string2'}>
<Link to={`getting-started/${this.props.message}`}>
     <h1>Under {this.props.message}/-</h1>
</Link>


如果您使用的是链接组件,那么您可以像这样连接:

<a data-featherlight={'string1' + this.props.data.imageUrl + 'string2'}>
<Link to={`getting-started/${this.props.message}`}>
     <h1>Under {this.props.message}/-</h1>
</Link>

在{this.props.message}下/-

据我所知,首先:

<a data-featherlight={'your string' + this.props.data.imageUrl}>

第二:

<a data-featherlight={`your string ${this.props.data.imageUrl}`}>


据我所知,首先:

<a data-featherlight={'your string' + this.props.data.imageUrl}>

第二:

<a data-featherlight={`your string ${this.props.data.imageUrl}`}>


这与2016年的公认答案有何不同?这与2016年的公认答案有何不同?我想将
图标={faTwitter}
中的
faTwitter
字符串与
faTwitter
连接起来。但是,这不接受
字符串
,因为它是
IconProp
类型。我们如何克服这个问题?我想把
faTwitter
Twitter
icon={faTwitter}
串接起来。但是,这不接受
字符串
,因为它是
IconProp
类型。我们如何克服这一点?