I don’t know why, the code in $(window).load() will not be executed. I think it should be a problem with requireJS loading, but I don’t know exactly what happened, so I can’t use $(window).load. () function, please help everyone, thank you very much! ! !
One benefit of using
requireJS
is that it can ensure that thejs module
is loaded in the order of dependencies you specify.Back to your code,
define
is used to define a module and indicate that the module depends onXyEason
. Therefore,requireJS
will ensure that the callback function, which isfunction(XyEason)
, is executed afterXyEason
is loaded. The execution of thecallback function is asynchronous, and the
load
event occurs when the page is loaded. By the time this code is executed, theload
event has already been triggered, so it will naturally not be executed.Your code is equivalent to the following paragraph
The key point is when you
require()
. If it is after the onload event, it will definitely not be triggered. I hope it can help you.