jQuery中的委托()与on()? [英] delegate() vs on() in jquery?

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

问题描述

我知道 delegate()和on()之间的区别,但我对此感到怀疑 on()

I know the difference between delegate() and on(), but I have a doubt that on() is very popular and faster than delegate() then why jquery is not removing the delegate() from its library.

live()有缺点,然后将其从jQuery-1.9 version中删除. 另外,如果我们看到on()和委托()之间的性能,则on()delegate()快得多.

live() has drawbacks then it is removed from jQuery-1.9 version. Also if we see the performance between on() and delegate() then on() is much faster than delegate().

那么有什么理由要在jQuery中保留proxy()?

Then any reason to keep delegate() in jQuery?

推荐答案

这是jQuery团队的成员写的关于此问题的信息在2013年:

This is what a member of the jQuery team wrote in regard to this issue in 2013:

我们尚未弃用.bind.delegate,也没有表明我们在 随时将其删除.

"We haven't deprecated .bind or .delegate, nor have we indicated we're removing them at any point.

它们在源中仅是一行,因此减小尺寸并不是删除它们的主要原因.

They're each only one line in the source so size reduction isn't much of a reason to remove them.

我们弃用了.live,因为它有很多我们无法解决的令人困惑的问题."

We deprecated .live because it has lots of confusing issues that we can't fix."

基本上,尽管delegate()已被on()取代,但由于它占用的空间很小(并且不会引起任何问题),因此没有未来的计划弃用delegate().

Basically, while delegate() has been superseded by on(), there are no future plans to deprecate delegate() due to the fact it takes up very little space (and doesn't cause any problems).

这篇关于jQuery中的委托()与on()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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