React useEffect附加脚本未触发

时间:2019-09-18 21:23:49

标签: javascript reactjs react-hooks use-effect

我正在尝试加载一个脚本,该脚本一旦触发就会生成iframe和天气小部件。我可以适当地添加脚本,但是不会被调用并且不会生成iframe

我尝试将脚本直接添加到渲染器中,它将短暂加载iframe,然后切换回脚本标签

    // this is a computed property
    get totalRows() {
        return this.SearchResultItems.length;
    }

1 个答案:

答案 0 :(得分:1)

注意控制台中显示的警告:

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.

请参见Execute write on doc: It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.