如何在 JSDoc 中记录事件处理程序?
假设我有一个这样的类:
function myClass(q) {
this.someFunction = function(e) {
console.log("Click event");
};
jQuery(q).click(this.someFunction);
}
有没有办法向 JSDoc 指示 someFunction 不仅仅是一个应该直接调用的函数,而是一个事件处理程序?
我看到了 @event 标签,但如果我理解正确的话,这更多的是记录我的类中的一个函数,我认为该函数是一个事件(客户端代码也会注册,并且我的类将在需要时触发)而不是事件处理程序功能 ?
Suppose I have a class like this:
function myClass(q) {
this.someFunction = function(e) {
console.log("Click event");
};
jQuery(q).click(this.someFunction);
}
Is there a way to indicate to JSDoc that someFunction is not just a function that should be invoked directly but rather is an event handler ?
I see the @event tag but if I understand correctly this is more to document a function in my class that I consider to be an event (something the client code would register too and that my class will fire when needed) and not an event handler function ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
关键字是 @listens
用法示例:
推论是 @fires 用于引发事件的关键字。
The keyword is @listens
Usage example:
The corollary is the @fires keyword for raising the event.
不,没有办法记录事件处理程序。因此,最好的方法是将其记录为普通函数,可能在其描述中用粗体文本或大写字母书写“事件处理程序”。
您可能已经知道了这一点,但以防万一:您可以通过简单地将文本包装到 html 标签中以粗体书写。
这答案现已弃用,但它不允许我删除它。
No, there is no way to document an event handler.So the best way is to document it as a normal function maybe writing in its description in bold text or upper case that is an "EVENT HANDLER".
You probably already now this, but just in case: you can write it in bold by simply wrapping the text into html tags<strong></strong>
.This answer is now deprecated but it does not let me delete it.