使用Meteor + React,如何将脚本添加到head标签?

Nea*_*int 3 meteor reactjs

我需要在我的网站上添加一个脚本标签,但我无法让它工作.

说明添加到网站的head标签,但我使用的是Meteor + React,并且没有html页面也是head标签来添加它.

在流星教程中它说

Meteor parses all of the HTML files in your app folder and identifies three top-level tags: <head>, <body>, and <template>.

Everything inside any <head> tags is added to the head section of the HTML sent to the client, and everything inside <body> tags is added to the body section, just like in a regular HTML file.
Run Code Online (Sandbox Code Playgroud)

所以我在客户端目录中添加了一个html文件,并在head标签内添加了脚本标签,但它不起作用.Meteor不会对我项目中的html文件进行任何更改.就好像html文件不存在一样.

我尝试使用jquery getScript在主布局组件安装后添加脚本,但这也不起作用.

Sau*_*uce 8

我有一段时间遇到同样的问题.我能够componentDidMount在高级组件中加载它.

componentDidMount () {
    function loadScript() {
         var script= document.createElement('script');
         script.type= 'text/javascript';
         script.src= 'yourURLhere.js';
         script.async = true;
         document.body.appendChild(script);
    }
    loadScript();
}
Run Code Online (Sandbox Code Playgroud)