Skip to content

请问一下 #1

@dbsg

Description

@dbsg

$(window).on("load", function () {
//不能影响最后的时间计算
window.setTimeout(function () {
_P.setup();
}, 0);
});
请问,这个定时器的作用是啥?

我之前遇到过这种情况,计算onload时间的时候,如果没有定时器返回的时间是错的。
window.onload = function () {
finishLoadTime() - startLoadTime() // 0 wrong
setTimeout(function () {
finishLoadTime() - startLoadTime() // 2000 right
},1)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions