在反应组件中加载外部脚本标记

时间:2016-09-25 18:58:36

标签: html dom reactjs

我正在建立一个选股申请。我发现这个图表模板非常棒,它带有一个html脚本:

<!-- TradingView Widget BEGIN -->
<div id="tv-medium-widget-b3840"></div>
<script type="text/javascript" src="https://d33t3vvu2t2yu5.cloudfront.net/tv.js"></script>
<script type="text/javascript">
new TradingView.Widget({
"container_id": "tv-medium-widget-b3840",
"symbols": [
[
  "Apple",
  "AAPL "
],
[
  "Google",
  "GOOGL"
],
[
  "Yahoo!",
  "YHOO"
]
],

"gridLineColor": "#e9e9ea",

"fontColor": "#83888D",

"underLineColor": "#dbeffb",

"trendLineColor": "#4bafe9",

"width": 1000,

"height": 350,

"tradeItWidget": false,

"locale": "en"

});
 </script>
<!-- TradingView Widget END -->

我的问题是我如何将它放在react-routing路由的react组件中?我只是在html中留下了脚本标签,并尝试在组件内调用构造函数,但它在所有页面上呈现为画布而不是路由器指向的那个。

const TradingViews = React.createClass({

componentDidMount:
   new TradingView.widget({

   "width": 980,
   "height": 610,
   "symbol": "QUANDL:YAHOO/FUND_FUSEX",
   "interval": "M",
   "timezone": "Etc/UTC",
   "theme": "White",
   "style": "1",
   "locale": "en",
   "toolbar_bg": "#f1f3f6",
   "enable_publishing": false,
   "allow_symbol_change": true,
   "hideideas": true,
   "show_popup_button": true,
   "popup_width": "1000",
   "popup_height": "650"


   }),

render:function(){
    return(
        null
    )

   }

});

export default TradingViews;

0 个答案:

没有答案
相关问题