Modal

Modal 顶/底部弹框

代码示例

import { BfModal } from '@bud-fe/react-taro-ui';
import { Button, View } from '@tarojs/components';
import React, { useState } from 'react';
export default () => {
const [baseOpened, setBaseOpened] = useState(false);
const [topOpened, setTopOpened] = useState(false);
return (
<>
<Button className="group-title" onClick={() => setBaseOpened(true)}>
基本用法
</Button>
<Button className="group-title" onClick={() => setTopOpened(true)}>
postion="top"
</Button>
<BfModal
isOpened={baseOpened}
styleMode="bf"
title="标题"
slotRight={<View style={{ color: 'red' }}>custom</View>}
subTitle="副标题"
onClose={() => {
console.log('onClose');
setBaseOpened(false);
}}
actionConfig={{
mode: 'doubleBtn',
onCancel: () => {
console.log('onCancel');
setBaseOpened(false);
},
onConfirm: () => {
console.log('onConfirm');
setBaseOpened(false);
},
}}
>
<View style={{ height: 200 }}>这里是内容</View>
</BfModal>
<BfModal isOpened={topOpened} title="标题" postion="top" onClose={() => setTopOpened(false)}>
<View style={{ height: 200 }}>这里是内容</View>
</BfModal>
</>
);
};

API

属性名描述类型默认值
isOpened是否打开booleanfalse
styleMode弹框样式"base" | "bf"'base'
title标题any--
subTitle副标题string--
slotRight标题栏右侧的插槽any--
titleSplit标题是否展示分割线booleanfalse
children自定义弹窗内容any--
postion弹窗位置 @deprecated - use position instead"top" | "bottom"bottom
position固定位置。默认为bottom"top" | "bottom"bottom
actionConfig吸底操作按钮配置Omit<IBfAffixProps, "children" | "layout" | "postion" | "position">--
onClose元素被关闭时候触发的事件,比如点击蒙层时。同 AtFloatLayout 的 onClose() => void--
dumi10:24