u010200767 2018-05-04 14:55 采纳率: 0%
浏览 708
已采纳

请问ngrx的auth.actions文件的这句export是什么意思?

export enum AuthActionTypes {
  Login = '[Auth] Login',
  Logout = '[Auth] Logout',
  LoginSuccess = '[Auth] Login Success',
  LoginFailure = '[Auth] Login Failure',
  LoginRedirect = '[Auth] Login Redirect'
}

export type AuthActions =
  | Login
  | LoginSuccess
  | LoginFailure
  | LoginRedirect
  | Logout;
第二个export是什么意思? “|” 是什么语法?
  • 写回答

1条回答 默认 最新

  • threenewbee 2018-05-04 16:15
    关注

    AuthActionTypes是一个枚举,包括5个可选值
    export是导出类型
    竖线语法叫做 String Literal Types

    String Literal Types
    String literal types allow you to specify the exact value a string must have. In practice string literal types combine nicely with union types, type guards, and type aliases. You can use these features together to get enum-like behavior with strings.

    也就是AuthActions虽然是字符串,但是只能取以上枚举的那几个值之一

    具体看
    http://www.typescriptlang.org/docs/handbook/advanced-types.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大