简体   繁体   English

如何在 Cordova 中几秒钟后执行 JS 代码?

[英]How to execute a JS code after some seconds in Cordova ?

I want to execute/run this code adSetter();我想执行/运行这段代码adSetter(); after 5 seconds. 5 秒后。 This code is in the deviceReady function.此代码位于 deviceReady 函数中。 The whole code is written in Javascript and using Cordova paltform.整个代码是用 Javascript 编写的,并使用 Cordova paltform。

How can I achieve my goal?我怎样才能实现我的目标?

setTimeout(function() {
    adSetter();
}, 5000);

The code above will wait 5000 milliseconds (5 seconds) before executing.上面的代码在执行前会等待 5000 毫秒(5 秒)。

Use timeout function使用超时功能

setTimeout(function(){
  // Do staff here
}, 5000);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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