doc注释法
在代码补全时或鼠标悬浮时提供注释说明
与typescript搭配,可以实现易于维护的代码
function
js
/**
* 获取店铺签约合同信息
* @access http://api.xxx.com/getUserNameByTagIdFromServer
* @param tagId 标签id {number}
* @returns name 用户名称 {string}
*/
async function queryUserNameByTagId(tagId: string) {
const userName = await getUserNameByTagIdFromServer(tagId);
return userName;
}
/**
* 获取店铺签约合同信息
* @access http://api.xxx.com/getUserNameByTagIdFromServer
* @param tagId 标签id {number}
* @returns name 用户名称 {string}
*/
async function queryUserNameByTagId(tagId: string) {
const userName = await getUserNameByTagIdFromServer(tagId);
return userName;
}
interface
js
interface IUser {
/**
* 用户姓名
*/
name: string;
/**
* 用户年龄
*/
age: number;
}
const user = {} as IUser;
user.age = 3;
user.name = '赵云';
interface IUser {
/**
* 用户姓名
*/
name: string;
/**
* 用户年龄
*/
age: number;
}
const user = {} as IUser;
user.age = 3;
user.name = '赵云';
@link
可以跳转至指定类型路径
enum
js
/**
* 水果枚举定义
* @param APPLE apple 苹果
* @param ORANGE orange 橘子
*/
enum EFruit {
/** 苹果 */
APPLE = 'apple',
/** 苹果 */
ORANGE = 'orange',
}
/**
* 水果枚举定义
* @param APPLE apple 苹果
* @param ORANGE orange 橘子
*/
enum EFruit {
/** 苹果 */
APPLE = 'apple',
/** 苹果 */
ORANGE = 'orange',
}
代码提示
js
/**
* Callback with latest motion values, fired max once per frame.
*
* ```jsx
* function onUpdate(latest) {
* console.log(latest.x, latest.opacity)
* }
*
* <Frame animate={{ x: 100, opacity: 0 }} onUpdate={onUpdate} />
* ```
*/
/**
* Callback with latest motion values, fired max once per frame.
*
* ```jsx
* function onUpdate(latest) {
* console.log(latest.x, latest.opacity)
* }
*
* <Frame animate={{ x: 100, opacity: 0 }} onUpdate={onUpdate} />
* ```
*/
单词添加背景色
js
/** `最高负荷` */
/** `最高负荷` */
无序列表
js
/**
* Given an input range of `[-200, -100, 100, 200]` and an output range of
*
* - When provided a value between `-200` and `-100`, will return a value between `0` and `1`.
* - When provided a value between `-100` and `100`, will return `1`.
* - When provided a value between `100` and `200`, will return a value between `1` and `0`
*/
/**
* Given an input range of `[-200, -100, 100, 200]` and an output range of
*
* - When provided a value between `-200` and `-100`, will return a value between `0` and `1`.
* - When provided a value between `-100` and `100`, will return `1`.
* - When provided a value between `100` and `200`, will return a value between `1` and `0`
*/