Popup

Popup 弹出层

代码示例

import { BfPopup } from '@bud-fe/react-taro-ui';
import { Button, View } from '@tarojs/components';
import React, { useState } from 'react';
export default () => {
const [visible, setVisible] = useState(false);
const [showTop, setShowTop] = useState(false);
const [showBottom, setShowBottom] = useState(false);
const [showLeft, setShowLeft] = useState(false);
const [showRight, setShowRight] = useState(false);
return (
<>
<View className="group-title">基础用法</View>
<Button onClick={() => setVisible(true)}>显示</Button>
<View className="group-title">弹出位置</View>
<Button onClick={() => setShowTop(true)}>顶部弹出</Button>
<Button onClick={() => setShowBottom(true)}>底部弹出</Button>
<Button onClick={() => setShowLeft(true)}>左侧弹出</Button>
<Button onClick={() => setShowRight(true)}>右侧弹出</Button>
<BfPopup visible={visible} style={{ padding: 30 }} onClose={() => setVisible(false)}>
正文
</BfPopup>
<BfPopup visible={showTop} style={{ height: '20%' }} position="top" onClose={() => setShowTop(false)} />
<BfPopup visible={showBottom} style={{ height: '20%' }} position="bottom" onClose={() => setShowBottom(false)} />
<BfPopup
visible={showLeft}
style={{ width: '50%', height: '100%' }}
position="left"
onClose={() => setShowLeft(false)}
/>
<BfPopup
visible={showRight}
style={{ width: '50%', height: '100%' }}
position="right"
onClose={() => setShowRight(false)}
/>
</>
);
};

API

属性名描述类型默认值
position弹出位置 top | bottom | left | right | centerstringcenter
overlayStyle自定义遮罩样式CSSProperties--
overlayClassName自定义遮罩类名string--
closeIcon关闭 Iconany--
closeIconPosition关闭按钮位置 top-left | top-right | bottom-left | bottom-rightstringtop-right
left标题左侧部分any--
title标题中间部分any--
description子标题/描述部分any--
mountOnEnter内容区元素是否只在动画开始时挂载booleantrue
destroyOnClose组件不可见时,卸载内容booleanfalse
portal指定节点挂载Teleport--
overlay是否显示遮罩booleantrue
round是否显示圆角booleanfalse
onOpen打开弹框时触发() => void--
onClose关闭弹框时触发() => void--
onOverlayClick点击遮罩触发(e: ITouchEvent) => boolean | void`() => true`
onCloseIconClick点击关闭图标时触发(e: ITouchEvent) => boolean | void`() => true``
onGetContentRef获取内容区的元素实例(ref: HTMLDivElement) => void--
dumi10:24