1. enum StatusCode {
    2. ok = 200,
    3. fail = 400,
    4. }
    5. let code: string | number = 200;
    6. if (code === StatusCode.ok) {
    7. console.log("成功");
    8. } else if (code === StatusCode.fail) {
    9. console.log("失败");
    10. }