我正在尝试使用ReactJS嵌入Gist,但是出现以下错误:
我将其从另一个组件内调用,代码如下:
有什么想法可以让这个工作起来吗?
这是我的组件代码:Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.
var EmbeddedGist = React.createClass({
render: function() {
return (
<div id="gist-container" />
);
},
componentDidMount: function() {
var src = this.props.srcUrl + ".js";
$('#gist-container').html('<script src="' + src + '"></script>');
}
});
我将其从另一个组件内调用,代码如下:
:
<EmbeddedGist srcUrl="https://gist.github.com/awalGarg/a5bd02978cecf3703f61" />
有什么想法可以让这个工作起来吗?