TuPopup 弹出层
top / right / bottom / left 四向滑入滑出,mask / maskClosable / round,close 事件。
从 top / right / bottom / left 四个方向滑入滑出的弹出层。根容器固定铺满视口、始终挂载,隐藏态通过 visibility + transform 离屏 + pointer-events 隔离交互,进入 / 退出动画全部由 CSS transition 驱动,无需 JS 计时。完全受控:visible 由父级维护,点击遮罩触发 close。
跨端
小程序端 WXSS 同样支持 transition / transform / visibility,同一份源码编译出完全一致的结构与动效。属性
| 名称 | 类型 | 说明 |
|---|---|---|
visible | boolean | 是否可见(受控),默认 false。 |
position | top | right | bottom | left | 弹出方向,默认 bottom。 |
mask | boolean | 显示遮罩,默认 true。 |
maskClosable | boolean | 点击遮罩是否触发 close,默认 true。 |
round | boolean | 面板圆角(bottom 顶部圆角 / 侧边内缘圆角),默认 true。 |
children | Array<VNode | string> | 面板内容(插槽)。 |
事件:close(点击遮罩且 maskClosable ≠ false 时触发)。
我是弹出面板:点遮罩或面板内按钮关闭
当前方向 bottom(已关闭) —— visible 受控,close 事件回传父级。
实例
ts
createComponent({
component: TuPopup,
props: { visible: this.state.sheetVisible, position: 'bottom', round: true },
children: [h('div', { className: 'sheet-body' }, ['底部面板内容'])],
emitters: { close: () => (this.state.sheetVisible = false) },
})