如何在 YUI3 中添加自定义实用程序/模块
我想在 YUI3 中注册一个自定义实用程序/模块,该实用程序/模块传递一个或多个自定义节点,并且可以像这样调用(无需实例化它):
YUI().use('myCustomModule', function (Y) {
Y.one('nodeToProcess').myCustomUtility(config);
Y.all('manyNodes').myCustomUtility(config);
});
jQuery 提供类似的功能。
我知道 YUI3 中的自定义模块是这样定义的:
YUI.add('myCustomModule', function(Y) {
// my Code here
}, '0.1', {
requires : ['node']
});
但我不明白的是如何设置我的自定义模块,以便我可以像所描述的那样调用它。我是否必须扩展插件/小部件类或使用 Y.Namespace() 才能使其正常工作? (参见http://www.slideshare.net/caridy/building-yui -3-自定义模块)
I would like to register a custom utility / module within YUI3 that is passed one or more custom node(s) and that can be called like this (without having to instantiate it):
YUI().use('myCustomModule', function (Y) {
Y.one('nodeToProcess').myCustomUtility(config);
Y.all('manyNodes').myCustomUtility(config);
});
jQuery offers a similar functionality.
I know that a custom module in YUI3 is defined like this:
YUI.add('myCustomModule', function(Y) {
// my Code here
}, '0.1', {
requires : ['node']
});
But what I don't understand is how to setup my custom module, so that I can call it like described. Do I have to extend Plugin / Widget class or use Y.Namespace() to get this to work? (see http://www.slideshare.net/caridy/building-yui-3-custom-modules )
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能想尝试这个:
You may want to try this: