Skip to content

isValidPlacement

验证 Placement 字符串是否有效。

函数签名

typescript
function isValidPlacement(placement: string): placement is Placement

type Placement = 
  | 'top' | 'top-start' | 'top-end'
  | 'bottom' | 'bottom-start' | 'bottom-end'
  | 'left' | 'left-start' | 'left-end'
  | 'right' | 'right-start' | 'right-end'

参数

参数名类型必填说明
placementstring待验证的定位字符串

返回值

类型说明
placement is Placement类型守卫,如果有效返回 true

工作原理

检查字符串是否为有效的 Placement 值,支持类型收窄。