js函數注釋規范


常用符號 說明 用法
@param 參數 @param {type} name
@return 返回值 @return {type}
/**
 * 測試
 * @param {number} num
 * @return {void}
 */
function test(num) {
  console.log(num);
}
/**
 * Enqueue a callback that will be executed after all the pending updates
 * have processed.
 *
 * @param {ReactClass} publicInstance The instance to use as `this` context.
 * @param {?function} callback Called after state is updated.
 * @param {string} callerName Name of the calling function in the public API.
 * @internal
 */
enqueueCallback: function(publicInstance, callback, callerName) {
  ReactUpdateQueue.validateCallback(callback, callerName);
  var internalInstance = getInternalInstanceReadyForUpdate(publicInstance);
  ...
}
/**
 * Checks whether or not this composite component is mounted.
 * @param {ReactClass} publicInstance The instance we want to test.
 * @return {boolean} True if mounted, false otherwise.
 * @protected
 * @final
 */
isMounted: function(publicInstance) {
  ...
}
/**
 * Generates root tag markup then recurses. This method has side effects and
 * is not idempotent.
 *
 * @internal
 * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
 * @param {?ReactDOMComponent} the containing DOM component instance
 * @param {?object} info about the native container
 * @param {object} context
 * @return {string} The computed markup.
 */
mountComponent: function(
  transaction,
  nativeParent,
  nativeContainerInfo,
  context
) {
  this._rootNodeID = globalIdCounter++;
  this._domID = nativeContainerInfo._idCounter++;
  this._nativeParent = nativeParent;
  this._nativeContainerInfo = nativeContainerInfo;
  ...
}
其他
@api: 提供給第三方使用的接口
@author: 標明作者
@param: 參數
@return: 返回值
@todo: 待辦
@version: 版本號
@inheritdoc: 文檔繼承
@property: 類屬性
@property-read: 只讀屬性
@property-write: 只寫屬性
@const: 常量
@deprecated: 過期方法
@example: 示例
@final: 標識類是終態, 禁止派生
@global: 指明引用的全局變量
@static: 標識類、方法、屬性是靜態的
@ignore: 忽略
@internal: 限內部使用
@license: 協議
@link: 鏈接,引用文檔等
@see: 與 link 類似, 可以訪問內部方法或類
@method: 方法
@package: 命名空間
@since: 從指定版本開始的變動
@throws: 拋出異常
@uses: 使用
@var: 變量
@copyright: 版權聲明

whosmeya.com


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM