【问题标题】:Does decorators in comments have any effect on code?注释中的装饰器对代码有影响吗?
【发布时间】:2019-08-16 08:11:39
【问题描述】:

我已经看到了一些装饰器在 cmets 中的代码,这些 cmets 被突出显示 - 请参阅来自 this code 的示例,所以我想知道这些代码行是否有任何影响。这是一个例子:

/**
 * Instanciate a new Payment.
 * @param payplugApi Object  The PayplugAPI with sucessfull authentication
 * @param paymentTracker String  A payment tracker (id) that will be send and received by PayPlug API to follow the payment. This tracked will be inserted in metadata
 * @param payment   Object  The payment options. More informations here : https://www.payplug.com/docs/api/apiref.html?powershell#create-a-payment
 * @return [nothing]
 * @see PayPlugAPI.authenticate The authentication method
 */
var Payment = function () {...}

只是文档还是执行代码?

任何提示都会很棒,谢谢!

【问题讨论】:

  • 提示:注释,无论其中包含什么内容,都会被 javascript 运行时忽略

标签: javascript decorator


【解决方案1】:

这些是 JSDoc comments 并被解析以生成文档(以及 IDE 中的“悬停”提示等)。他们与装饰者没有关系。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-02-10
    • 2017-08-27
    • 2021-11-20
    • 2022-09-21
    • 2015-11-20
    • 2011-08-06
    • 2023-01-15
    • 2020-11-12
    相关资源
    最近更新 更多