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><BfModalisOpened={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 | 是否打开 | boolean | false |
styleMode | 弹框样式 | "base" | "bf" | 'base' |
title | 标题 | any | -- |
subTitle | 副标题 | string | -- |
slotRight | 标题栏右侧的插槽 | any | -- |
titleSplit | 标题是否展示分割线 | boolean | false |
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 | -- |