简体   繁体   中英

OnsenUI : uncaught ReferenceError: setImmediate is not defined

Onsen UI throwing error while dynamically rendering the onsen's js and css. But It's working when i using it in static htmls. Error: Uncaught ReferenceError: setImmediate is not defined

    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

My code.,

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>');


                    });

I solved adding this to the header tag

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM