JSDoc 中文网

概述

¥Overview

@readonly 标签指示符号是只读的。请注意,这仅用于文档目的 - JSDoc 不会检查你是否确实在代码中将该符号视为只读。

¥The @readonly tag indicates that a symbol is intended to be read-only. Note this is for the purpose of documentation only - JSDoc won't check whether you've actually treated the symbol as read-only in your code.

示例

¥Examples

使用@readonly 标签
/**

 * A constant.

 * @readonly

 * @const {number}
 */
const FOO = 1;
将 @readonly 标签与 getter 一起使用
/**

 * Options for ordering a delicious slice of pie.

 * @namespace
 */
var pieOptions = {
	/**

	 * Plain.
	 */
	plain: 'pie',
	/**

	 * A la mode.

	 * @readonly
	 */
	get aLaMode() {
		return this.plain + ' with ice cream';
	}
};