本文介绍了Angular2中路由器的延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这段代码,它具有2个功能:say()
将播放音乐(已实现并且可以运行)并且router
转到下一页(也可以)
I have this code, which have 2 functions:say()
will play the music (is implemented and it works)and router
leads to next page (it works also)
go_next() {
this.say(); // audio
this.router.navigate( ['app'], { queryParams: { 'part': this.part+1 } } ); //go to next page
}
但是我想做的是播放音乐(需要5秒钟),然后转到下一页...我该如何实现呢?.我想,我必须实现某种delay
,但是router.navigate
我找不到这样的参数.
But what I would like to do is to play music (it takes 5 sec) and then to go to the next page...how could I implement this?..I guess, I have to implement some kind of delay
, but I can't find such parameter by router.navigate
.
推荐答案
go_next(){
setTimeout(() => {
this.router.navigate(['app'], {queryParams: {'part': this.part + 1}})
}
, 5000);
}
这篇关于Angular2中路由器的延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!