我如何嵌入<script>?

时间:2018-02-13 06:27:51

标签: reactjs amazonads

我对Reactjs很新。我有来自亚马逊的代码来嵌入一个添加,但它只给我版本,据我所知,我不能在React中使用。是否有解决方法?

&#xA;&#xA;

亚马逊代码:

&#xA;&#xA;
 &lt; script type =“text / javascript“&gt;&#xA; amzn_assoc_placement =”adunit0“;&#xA; amzn_assoc_search_bar =”true“;&#xA; amzn_assoc_tracking_id =”***“;&#xA; amzn_assoc_search_bar_position =”bottom“;&#xA; amzn_assoc_ad_mode =“search”;&#xA; amzn_assoc_ad_type =“smart”;&#xA; amzn_assoc_marketplace =“amazon”;&#xA; amzn_assoc_region =“US”;&#xA; amzn_assoc_title =“商店相关产品”;&# xA; amzn_assoc_default_search_phrase =“狗玩具”;&#xA; amzn_assoc_default_category =“全部”;&#xA; amzn_assoc_linkid =“***”;&#xA;&lt; / script&gt;&#xA;&lt; script src =“ //z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US"></script>

1 个答案:

答案 0 :(得分:0)

<script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US"></script>

AmazonEmbededCode(){
    amzn_assoc_placement = "adunit0";
    amzn_assoc_search_bar = "true";
    amzn_assoc_tracking_id = "***";
    amzn_assoc_search_bar_position = "bottom";
    amzn_assoc_ad_mode = "search";
    amzn_assoc_ad_type = "smart";
    amzn_assoc_marketplace = "amazon";
    amzn_assoc_region = "US";
    amzn_assoc_title = "Shop Related Products";
    amzn_assoc_default_search_phrase = "Dog Toys";
    amzn_assoc_default_category = "All";
    amzn_assoc_linkid = "***";
 }

你需要在你的div中调用这个函数

<div className="amazon-div" onLoad={this.AmazonEmbededCode()}>
    embed code here...
 </div>