标签:方法 set ams 返回 nts this 解决 var wan
如题,在异步加载获取页面数据时,有时会调用其他组件,当在传参时有时并不是所有参数都已加载。
异步加载数据获取异常的解决方法:setInterval()
setInterval()这个方法可按照指定的周期(以毫秒计)来调用函数或计算表达式。
setInterval(x(),y);
x()代表你调用的方法,
y是每隔多长时间调用一次x()方法
例如: setInterval(x(),1000);
每隔1秒调用一次x()方法
如下: var stv = setInterval(() => {},1000);
在{}的方法里面调用clearInterval(stv ) 方法,把返回值作为参数。
示例代码如下:
var stv = setInterval(() => {
var id = this.id;
if(id !=0 && id != undefined){
clearInterval(stv);
//todo
}
},1000);
后记:There are mements in life when you miss someone so much that you just want to pick them from your dreams and hug them for real!
Dream what you want to dream,go where you want to go,be what you want to be,
because you have only one life and one chance to do all the things you want to do.
标签:方法 set ams 返回 nts this 解决 var wan
原文地址:https://www.cnblogs.com/UsefulIdiot/p/12213403.html