fuermosi777
V2EX  ›  React

有人知道 React 模块里怎么加入百度联盟广告么?

  •  
  •   fuermosi777 · Sep 9, 2015 · 2739 views
    This topic created in 4004 days ago, the information mentioned may be changed or developed.

    官方提供的代码是加入一个 script 标签,然后会 document.write 一个 iframe 里展示广告。但是在 React 里无法使用(因为不能动态添加 script 标签)。我试过这样:

    componentDidMount () {
    let g = document.createElement ('script');
    g.setAttribute ('src','....js');
    React.findDOMNode (this.refs.ad ).appendChild (g );
    }

    给出错误提示 It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.

    请问怎么能加入广告呢?谢谢!

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3127 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 13:19 · PVG 21:19 · LAX 06:19 · JFK 09:19
    ♥ Do have faith in what you're doing.