如何添加Amazone广告脚本Inside ReactJs组件

时间:2017-01-17 14:10:46

标签: reactjs

如何在空间位置将脚本集成到react组件中, 以下是用于显示添加的脚本,当我通过w3schools

上的脚本时,它会起作用
In [29]: np.take(A, np.arange(ncols)%A.shape[1], axis=1)
Out[29]: 
array([[0, 1, 0, 1, 0, 1, 0],
       [2, 3, 2, 3, 2, 3, 2]])

我喜欢做什么

<div class="alignleft">
  <script type="text/javascript">
  amzn_assoc_ad_type = "banner";
    amzn_assoc_marketplace = "amazon";
    amzn_assoc_region = "US";
    amzn_assoc_placement = "assoc_banner_placement_default";
    amzn_assoc_campaigns = "kuft";
    amzn_assoc_banner_type = "category";
    amzn_assoc_p = "48";
    amzn_assoc_isresponsive = "false";
    amzn_assoc_banner_id = ID;
    amzn_assoc_width = "728";
    amzn_assoc_height = "90";
    amzn_assoc_tracking_id = "reater-20";
    amzn_assoc_linkid = amzn_assoc_linkid;
  </script>
  <script src="//z-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&Operation=GetScript&ID=OneJS&WS=1"></script>
</div>

2 个答案:

答案 0 :(得分:0)

我已经解决了这个问题,

var React = require('react');

var AmazoneAdd = React.createClass({
  amazoneScript: function() {
    return '<div class="alignleft"> <script type="text/javascript"> amzn_assoc_ad_type = "banner"; amzn_assoc_marketplace = "amazon"; amzn_assoc_region = "US"; amzn_assoc_placement = "assoc_banner_placement_default"; amzn_assoc_campaigns = "kuft"; amzn_assoc_banner_type = "category"; amzn_assoc_p = "48"; amzn_assoc_isresponsive = "false"; amzn_assoc_banner_id = ID; amzn_assoc_width = "728"; amzn_assoc_height = "90"; amzn_assoc_tracking_id = "reater-20"; amzn_assoc_linkid = "asoc_linked"; </script> <script src="//z-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&Operation=GetScript&ID=OneJS&WS=1"></script> </div>'
  },
  render: function() {
    return (
      <div >
        functionality data goes here....
        ...
        <div className='advertisement'>
          <div dangerouslySetInnerHTML={{__html: this.amazoneScript()}}></div> 
        </div>
      </div>
    );
  }
});

module.exports = AmazoneAdd;

答案 1 :(得分:0)

只需使用iframe选项,它就可以正常工作。而且您不会永远留在Amazon Associates