Skip to content

getBasePlacement

从完整的 Placement 字符串中提取基础定位方向(top/right/bottom/left)。

函数签名

typescript
function getBasePlacement(placement: Placement): BasePlacement

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

type BasePlacement = 'top' | 'right' | 'bottom' | 'left'

参数

参数名类型必填说明
placementPlacement完整的定位说明,可能包含对齐方式

返回值

类型说明
BasePlacement基础定位方向(top/right/bottom/left)

工作原理

  1. 将 Placement 字符串按 - 分割
  2. 返回第一部分作为基础定位方向

示例

  • getBasePlacement('top')'top'
  • getBasePlacement('top-start')'top'
  • getBasePlacement('bottom-end')'bottom'