Html 在引导前等待n秒,角度2
我正在Angular 2中制作一个空间/重力游戏,目前希望在主菜单组件加载之前有一个初始屏幕 我认为最简单的方法是简单地使用预引导的index.html内容,例如:Html 在引导前等待n秒,角度2,html,css,angular,typescript,Html,Css,Angular,Typescript,我正在Angular 2中制作一个空间/重力游戏,目前希望在主菜单组件加载之前有一个初始屏幕 我认为最简单的方法是简单地使用预引导的index.html内容,例如: <body> <!-- //This is where our bootstrapped content will go. //Because everything will be removed from the DOM after bootstrap,
<body>
<!--
//This is where our bootstrapped content will go.
//Because everything will be removed from the DOM after bootstrap,
//we can consider this pre-bootstrapped index.html as a psuedo "splash screen"
//(anim credit @ http://codepen.io/katehummer/pen/zrygBM)
-->
<!--<app-mainmenu>-->
<svg class="solar-system">
<circle id="sun" cx="100" cy="100" r="10" stroke="none" fill="#FFE581" />
<circle id="mercury" cx="100" cy="100" r="3" fill="#fff" stroke="none" />
<circle id="venus" cx="100" cy="100" r="4" fill="#fff" stroke="none" />
<circle id="earth" cx="100" cy="100" r="5" fill="#fff" stroke="none" />
<circle id="mars" cx="100" cy="100" r="5" fill="#fff" stroke="none" />
<circle id="mercury-orbit" cx="100" cy="100" r="35" fill="none" stroke="rgba(255,255,255,0.2)" stroke-width="0.5" />
<circle id="venus-orbit" cx="100" cy="100" r="55" fill="none" stroke="rgba(255,255,255,0.2)" stroke-width="0.5" />
<circle id="earth-orbit" cx="100" cy="100" r="75" fill="none" stroke="rgba(255,255,255,0.2)" stroke-width="0.5" />
<circle id="mars-orbit" cx="100" cy="100" r="95" fill="none" stroke="rgba(255,255,255,0.2)" stroke-width="0.5" />
</svg>
<!--
//WAIT 10 SECONDS MINIMUM - OR WAIT UNTIL USER LOADS IF AFTER 10 SEC
-->
<!--</app-mainmenu>-->
</body>
当
被注释掉时,我可以成功地测试我的动画。它看起来就像注释中引用的那个
下一步是告诉Angular在引导前等待10秒。我在底部尝试了一个JS延迟,但是因为它没有阻塞,所以没有工作
<script>
setInterval(tryFinishLoading, 10000);
function tryFinishLoading() {
alert("loaded");
}
</script>
设置间隔(tryFinishLoading,10000);
函数tryFinishLoading(){
警报(“已加载”);
}
有人能告诉我如何等待以下信息:
1) 要加载的用户,如果<10,请转到(2)
2) 等待10,如果未加载,则循环直到加载
干杯 这应该能奏效
<body>
<app-mainmenu id="main" style="display:none"></app-mainmenu>
<svg id="anim">Your Animation</svg>
<script>
var anim = document.getElementById('anim');
var main = document.getElementById('main');
setTimeout(function() {
anim.style.display = 'none';
main.style.display = 'block';
}, 10000);
</script>
</body>
你的动画
var anim=document.getElementById('anim');
var main=document.getElementById('main');
setTimeout(函数(){
anim.style.display='none';
main.style.display='block';
}, 10000);
隐藏根组件(应用程序主菜单)并显示动画10秒,10秒后显示组件并隐藏动画如何?使用JavaScript显示/隐藏老把戏!创建角度组件飞溅。让它成为引导的第一个组件。经过所需的启动延迟时间后,您可以通过导航到不同的页面来切换到不同的页面component@SabbirRahman这是个好主意,但我认为不可能,因为在组件启动后,先前的内容将从DOM中删除-因此,虽然这将成功地允许我们在显示主菜单组件之前等待10秒,但启动屏幕将比此更早地从DOM中删除:(@VinitSarvade这是个好主意,但我主要关心的是这种方法会导致加载过多而没有什么好处-我认为必须有一种更简单的方法。@Kevin好的,splash会保存svg内容。因此它会作为第一个组件加载。不会删除任何内容。默认情况下,你的应用程序菜单将保持为空。它会尽快保存splashangular是bootstrappedAwesome,所以您将引导代码放在启动代码之外,所以当它准备好时,它不会取代启动代码,对吗?它可以工作!