【问题标题】:Embed javascript component in meteorjs [duplicate]在meteorjs中嵌入javascript组件[重复]
【发布时间】:2016-01-01 08:26:03
【问题描述】:

如何将这样的脚本嵌入到一个流星应用程序(使用 Iron-router)中的模板中?

<!-- TradingView Widget BEGIN -->
<script type="text/javascript" src="https://d33t3vvu2t2yu5.cloudfront.net/tv.js"></script>
<script type="text/javascript">
new TradingView.widget({
  "width": 980,
  "height": 610,
  "symbol": "FX:SPX500",
  "interval": "D",
  "timezone": "exchange",
  "theme": "White",
  // other stuffs...
});
</script>

我得到了小部件 sn-p here
Here 是我的示例代码:应用程序不显示任何图表。

【问题讨论】:

    标签: javascript meteor meteor-blaze meteor-helper


    【解决方案1】:

    如果您使用 Iron Router,插入头部内容目前不实用。会造成双头标签的情况。

    最简单的方法是创建一个包含脚本内容的 JS 文件。 Meteor 会自动将它与任何其他 JS 一起包含在您应用的头部。

    但实际上,我可能会将其作为

    Template.app.onRendered(function() {
    new TradingView.widget({
      "width": 980,
      "height": 610,
      "symbol": "FX:SPX500",
      "interval": "D",
      "timezone": "exchange",
      "theme": "White",
      // other stuffs...
    
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-06
      • 2011-08-19
      • 2016-11-29
      • 2017-06-03
      • 1970-01-01
      相关资源
      最近更新 更多