可以jquery实现类继承像原型 [英] can jquery implement the class inherit like prototype

查看:107
本文介绍了可以jquery实现类继承像原型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试为我们的应用程序选择一个JavaScript框架。

We are trying to choose a JavaScript framework for our application.

它归结为JQuery或Prototype。

It's come down to either JQuery or Prototype.

JQuery有很多东西可以提供,比如动画和效果,还有DOM的简单遍历和变异。 JQuery的另一个优点是可用的大量插件。

The JQuery has a lot to offer, like animation and effects, also easy traversal and mutation of the DOM. Another strong point of JQuery are the vast number of plugins available.

但似乎原型具有更好的继承模型,因为它允许开发人员轻松扩展类。

But it seems that the prototype has a better inheritance model, in that, it allows the developer to easily extend classes.

我的个人偏好是JQuery,但我真的想知道,JQuery会帮助我继承/扩展类吗?

My personal preference is JQuery, but I would really like to know, would JQuery help me in inheriting/extending classes ?

推荐答案

jQuery的创建者John Resig故意避免在jQuery本身中实例化(通过 new 关键字)。但是,他已经编写了一个聪明的脚本,以便在javascript中提供一个简单的类继承模型,而不依赖于任何其他框架。

John Resig, the creator of jQuery, intentionally avoided the need for instantiation (via the new keyword) in jQuery itself. However, he has written a clever script to provide a simple class inheritance model in javascript generally, without relying on any other framework.

我曾经使用prototype.js,但是现在jQuery几乎已成为标准的javascript库。可以将它们一起使用,但是如果您只是在寻找继承架构,那么prototype.js将代表很多开销。我建议坚持使用jQuery,并使用John Resig的Class脚本来实现对你有意义的继承。

I used to use prototype.js, but jQuery has practically become the standard javascript library these days. It is possible to use them together, but prototype.js would represent a lot of overhead if you're just looking for an inheritance architecture. I'd suggest sticking with jQuery, and use John Resig's Class script to implement inheritance where it makes sense for you.

这篇关于可以jquery实现类继承像原型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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