1.0.0-beta.62 • Published 3 years ago

@rax-ui/dialog v1.0.0-beta.62

Weekly downloads
54
License
-
Repository
-
Last release
3 years ago

display: Dialog

family: other

Dialog

对话框

API

Dialog

参数说明类型默认值
visible是否显示boolfalse
type对话框类型'none' / 'alert' / 'confirm'false
keepMounted是否一直存在booleanfalse
hideBackdrop是否隐藏遮盖背景booleanfalse
disableBackdropClose是否禁用背景点击关闭booleanfalse
title对话框的标题内容node
icon对话框的图标, 支持传入图标名称或者图片 URL 路径string
iconColor图标的颜色类型 可选值: success, notice, warning, error, normalenumnormal
message对话框的文字内容string
close是否显示关闭按钮boolfalse
free是否是自由模式,设置为 true 只有关闭按钮的位置和样式将会发生变化boolfalse
buttons对话框底部按钮DialogButtonProps[][]
buttonDirection按钮排列方向 可选值: row, columnenumrow
renderBanner渲染对话框 banner 部分的内容():node
onOk确定按钮被点击时回调(e) => void;
onCancel取消按钮被点击时回调(e) => void;
onButtonClick按钮被点击时回调(index?: number, e?: any) => void;
onHide当对话框遮盖层点击或者点击关闭按钮时回调(reason: string, e) => void
onEnter开始进入时回调函数() => void
onExit开始退出时回调函数() => void
onEntering正在进入时回调函数() => void
onExiting正在退出时回调函数() => void
onEntered进入后回调函数() => void
onExited退出后回调函数() => void
onBackdropClick遮盖背景被点击时调用() => void
onClose关闭时调用(reason: string) => void
children对话框的内容node

DialogButtonProps

参数说明类型默认值
text按钮文字string
onClick点击之后回调 【小程序支持旧版本存在风险】(e) => void
style按钮样式CSSProperties
textStyle按钮文字样式CSSProperties

函数式调用 (WEB, Weex)

import Dialog from '@rax-ui/dialog';

// 提示
Dialog.alert({
  message: 'Hello alert',
  button: '自定义按钮' // 默认确定
}, () => {
  console.log('callback')
});

// 确认
Dialog.confirm({
  title: 'title',
  message: 'Hello alert',
  okButton: '自定义确定', // 默认确定
  cancelButton: '自定义取消', // 默认取消
}, (e) => {
  console.log(e.ok); // 是否点击确定
});

// 自定义内容和按钮
const hide = Dialog.show({
  title: 'title',
  content: (
    <View>
      <Text>自定义内容</Text>
    </View>
  ),
  buttons: [
    '知道了',
    {
      a: 1,
      b: 2,
      text: '关闭',
      style: { // 自定义按钮样式
        backgroundColor: 'red'
      },
      textStyle: { // 自定义按钮文案样式
        color: 'white'
      }
    }
  ]
}, (e) => {
  console.log(e); // 包含 button 里的属性如 e.a, e.b
  hide(); // 需要手动关闭
});

组件式调用

import { useState } from 'rax';
import Dialog from '@rax-ui/dialog';

function App() {
  const [visible, setVisible] = useState(true);
  return (
    <Dialog
      title="标题"
      visible={visible}
      buttons={[{ text: '确定', onClick: () => setVisible(false)}]}
    >
      <View>自定义内容</View>
    </Dialog>
  )
}

CSS API

详细见 src/style/index.ts

1.0.0-beta.62

3 years ago

1.0.0-beta.60

4 years ago

1.0.0-beta.59

4 years ago

1.0.0-beta.57

4 years ago

1.0.0-beta.56

4 years ago

1.0.0-beta.55

4 years ago

1.0.0-beta.54

4 years ago

1.0.0-beta.53

4 years ago

1.0.0-beta.52

4 years ago

1.0.0-beta.51

4 years ago

1.0.0-beta.50

4 years ago

1.0.0-beta.48

4 years ago

1.0.0-beta.49

4 years ago

1.0.0-beta.47

4 years ago

1.0.0-beta.45

4 years ago

1.0.0-beta.46

4 years ago

1.0.0-beta.43

4 years ago

1.0.0-beta.42

4 years ago

1.0.0-beta.41

4 years ago

1.0.0-beta.40

4 years ago

1.0.0-beta.39

4 years ago

1.0.0-beta.38

4 years ago

1.0.0-beta.37

4 years ago

1.0.0-beta.36

4 years ago

1.0.0-beta.35

4 years ago

1.0.0-beta.32

4 years ago

1.0.0-beta.30

4 years ago

1.0.0-beta.29

4 years ago

1.0.0-beta.28

4 years ago

1.0.0-beta.27

4 years ago

1.0.0-beta.26

4 years ago

1.0.0-beta.24

4 years ago

1.0.0-beta.23

4 years ago

1.0.0-beta.22

4 years ago

1.0.0-beta.21

4 years ago

1.0.0-beta.20

4 years ago

1.0.0-beta.18

4 years ago

1.0.0-beta.17

4 years ago

1.0.0-beta.16

4 years ago

1.0.0-beta.15

4 years ago

1.0.0-beta.14

4 years ago

1.0.0-beta.13

5 years ago

1.0.0-beta.10

5 years ago

1.0.0-beta.9

5 years ago

1.0.0-beta.6

5 years ago

1.0.0-beta.5

5 years ago

1.0.0-beta.3

5 years ago

1.0.0-beta.2

5 years ago

1.0.0-beta.1

5 years ago

1.0.0-beta

5 years ago

1.0.0-beta.0

5 years ago