load()方法已弃用? [英] load() method deprecated?

查看:138
本文介绍了load()方法已弃用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在浏览jQuery api时发现不推荐使用 load方法列表.

I was browsing through the jQuery api and noticed that the load method is on the deprecated list.

类别:已弃用|活动>文档加载

Categories: Deprecated | Events > Document Loading

我通常使用这种方法来检查是否完全加载了图像.为什么不推荐使用?而我应该用什么代替呢?

I usually use this method to check if images are completly loaded. Why is it deprecated? And what am I supposed to be using instead?

推荐答案

请参见错误#11733 ,其中记录了此弃用情况:

See bug #11733, which documents this deprecation:

.load()方法是模棱两可的签名,它可以是ajax 加载或附加/触发加载"事件. CCAO 无法区分它们,因为 这是基于参数的动态决策.

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().例如:

To avoid ambiguities related to the method's signature, it is now recommended to use on() instead. For instance:

$("selector").load(function() {
    // ...
});

应成为:

$("selector").on("load", function() {
    // ...
});

这篇关于load()方法已弃用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆