如何创建包装器
当我在 Google 上搜索特定内容时,我多次遇到“创建包装器并扩展它”的概念。就我而言,我想扩展 DOM。我知道人们多么反对这样做,但我想做的事情略有不同,要做到这一点,我至少需要探索这些方法。因此,无论我查看什么博客/wiki/tut,都没有得到直接答案,我向您提出的问题是:什么是包装对象/函数以及如何制作和使用它?
抱歉,如果事实证明我说得毫无道理;当我读到原型库和 JQuery 曾经做过此类事情时,我得到了这个想法。如果您能使用 DOM 作为示例,我们将不胜感激。
As I Googled particular things, I've numerously run into the concept of "create a wrapper and extend that." In my case, I want to extend DOM. I know how advised against that is, but what I'm trying to do is slightly different and to do it I need to at-least explore these methodologies. So my question to you, after not getting a straight answer nomatter what blog/wiki/tut I looked at, is: What is a wrapper object/function and how do you make and use one?
Sorry if it turns out I made no sense; I'm getting this idea from when I read that prototype library and JQuery did things of these sorts once upon a time. If you could use DOM as an example, it would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
愚蠢的例子,假设
将 DOM 元素
my_div
包装在MyDiv
内允许您可以过滤(或增强)包装对象的接口。Silly example, assuming
<div id='my-div'></div>
Wrapping the DOM element
my_div
insideMyDiv
allows you to filter (or augment) the wrapped object's interface.