我正在浏览 jQuery api 并注意到 load method已在弃用列表中。
Categories: Deprecated | Events > Document Loading
我通常使用此方法来检查图像是否已完全加载。为什么它被弃用?我应该用什么来代替?
最佳答案
参见bug #11733 ,它记录了此弃用:
The
.load()
method is an ambiguous signature, it can either be an ajax load or attach/fire a "load" event. CCAO cannot tell them apart since it's a dynamic decision based on arguments.
为了避免与方法签名相关的歧义,现在建议使用 on()反而。例如:
$("selector").load(function() {
// ...
});
应该变成:
$("selector").on("load", function() {
// ...
});
关于jquery - load() 方法已弃用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12643160/