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'参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
placement | Placement | 是 | 完整的定位说明,可能包含对齐方式 |
返回值
| 类型 | 说明 |
|---|---|
BasePlacement | 基础定位方向(top/right/bottom/left) |
工作原理
- 将 Placement 字符串按
-分割 - 返回第一部分作为基础定位方向
示例:
getBasePlacement('top')→'top'getBasePlacement('top-start')→'top'getBasePlacement('bottom-end')→'bottom'