Pass timeout to Foundation 6 loading

橙三吉。 提交于 2019-12-24 08:58:25

问题


I'm using Angular2 and Foundation 6 for creating a webapp. I generate by myself scripts and styles from Foundation .scss files.

Here is my index.html

<html>
    <head>
        <title>MyApp</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
        <script src="scripts/foundation.min.js"></script>
        <link rel="stylesheet" href="styles/foundation.css">
    </head>
    <body>
        <my-app>Loading...</my-app>

        <script src="node_modules/core-js/client/shim.min.js"></script>
        <script src="node_modules/zone.js/dist/zone.js"></script>
        <script src="node_modules/reflect-metadata/Reflect.js"></script>
        <script src="node_modules/systemjs/dist/system.src.js"></script>
        <script src="systemjs.config.js"></script>
        <script>
            System.import('app').catch(function(err) { console.error(err); });

            setTimeout(function () {
                $(document).foundation();
            }, 2000);
        </script>
    </body>
</html>

As you can see i had to add a timeout to correctly load some Foundation building blocks. If i remove that timeout Foundation doesn't work and then its classes don't work.

What is the right way to handle this kind of problem? Why i'm getting problem with Foundation loading?

来源:https://stackoverflow.com/questions/39492491/pass-timeout-to-foundation-6-loading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!