问题
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