动态呈现Onsen的js和CSS时Onsen UI抛出错误。但是,当我在静态htmls中使用它时,它正在工作。
错误:未捕获ReferenceError:未定义setImmediate

    internal.js:52 Uncaught ReferenceError: setImmediate is not defined
        at Object.internal$1.waitDOMContentLoaded (internal.js:52)
        at internal.js:103
        at onsElements (onsenui.js:6)
        at onsenui.js:7


我的代码。,

jsResource = ['https://cdnjs.cloudflare.com/ajax/libs/onsen/2.10.4/js/onsenui.js'];

    async.mapSeries(jsResource, function (file, callback3) {
                        // console.log('Enter FILE =>',file)
                        if (file) {
                            var jsFile = iframedocument.createElement('script');
                            jsFile.setAttribute('type', 'text/javascript');
                            jsFile.setAttribute('src', file);
                            head.appendChild(jsFile);

                            if (jsFile.readyState) {  //IE
                                jsFile.onreadystatechange = function () {
                                    if (s.readyState == "loaded" ||
                                        s.readyState == "complete") {
                                        s.onreadystatechange = null;
                                        callback3(null, null);
                                    } else {
                                        callback3(null, null);
                                    }
                                };
                            } else {  //Others
                                jsFile.onload = function () {
                                    callback3(null, null);
                                };
                            }

                        }
                        else {
                            callback3(null, null);
                        }
                    }, function (err, result) {
                        body.append('<script>' + resultData + '</script><script>' + jsCode + '</script>');


                    });

最佳答案

我解决了将其添加到标题标签中

<script>
     window.setImmediate = window.setTimeout;
</script>

关于javascript - OnsenUI:未捕获的ReferenceError:未定义setImmediate,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52164025/

10-09 23:39