📜  枚举使用打字稿代码示例

📅  最后修改于: 2022-03-11 14:48:31.945000             🧑  作者: Mango

代码示例1
enum UserResponse {
  No = 0,
  Yes = 1,
}

function respond(recipient: string, message: UserResponse): void {
  console.log(recipient, message); // "Princess Caroline",  1
}

respond("Princess Caroline", UserResponse.Yes);