Skip to content

浮层 Provider

@astryxdesign/core v0.7.1 · LayerProvider

属性 ​

属性类型默认值说明
toastLayerToastConfig—toast 视口的配置:position 贴哪个角、maxVisible 最多显示几条,还有一个只对 toast 生效的 inset,会逐边盖掉 provider 上的同一条边。
insetLayerInset每条边 0浮在视口某条边上的常驻条,声明一次就够:blockStart、blockEnd、inlineStart、inlineEnd,写数字就是像素,也可以写 CSS 长度。每条边会加到所有贴边浮层离那条边的空隙上,toast 视口也按同样的量挪进去。

插槽 ​

插槽说明
default应用子树,可以读取这份共享的浮层配置。

LayerToastConfig ​

字段类型默认值说明
positionToastPlacement'bottom-end'toast 视口贴在哪个角:top-start、top-center、top-end、bottom-start、bottom-center、bottom-end。直接写在 ToastViewport 上的 placement 优先。
maxVisiblenumber不限制同时最多显示几条。超出的先不渲染,只留最新的那几条。
insetLayerInset—只对 toast 视口生效的逐边偏移。这条边写了就用它,没写的边继续用 provider 的 inset。

LayerInset ​

字段类型说明
blockStartnumber | string加在顶部空隙上的偏移。数字按像素算,字符串可以是任意 CSS 长度,例如 '4rem' 或 'env(safe-area-inset-top, 0px)'。
blockEndnumber | string同上,底部那条边。
inlineStartnumber | string同上,行首那条边。
inlineEndnumber | string同上,行尾那条边。

其它导出 ​

导出类型说明
useLayerConfig() => ComputedRef<LayerContextValue> | null读最近一层 provider 的配置,外层没有就是 null。
useLayerGutter() => ComputedRef<LayerGutter>贴边浮层离视口每条边的距离:间距第 4 档和设备安全区取大,再加上 provider 的偏移。
resolveInset(inset?: LayerInset) => ResolvedLayerInset把一份 inset 换算成像素。
mergeInset(primary?: LayerInset, fallback?: LayerInset) => ResolvedLayerInset逐边合并两份 inset:primary 写了的边用它,剩下的从 fallback 来。

原生属性 ​

组件本身不渲染元素,class 和 style 不会传下去。