mCloud Design Mobile

mCloud Design Mobile

  • Docs
  • API
  • Help
  • Blog

›Component

Component

  • Button
  • SegmentedControl
  • SearchBar
  • Radio
  • Checkbox
  • Badge
  • Marquee
  • Switch
  • InputItem
  • NoticeBar
  • Textarea
  • List
  • Card
  • Picker
  • Label
  • EmptyView
  • Stepper
  • Tabs
  • DatePicker
  • Modal
  • Avatar
  • ActionSheet
  • ShareSheet

First Category

  • Button
  • Fifth Document

Modal

滚动文字组件

Basic Example:

import React from 'react'
import { View } from 'react-native'
import { Button, Modal } from 'mcloud-mobile'

export default class ModalDemo extends React.Component {
    render() {
        return (
            <View style={{ flex: 1 }}>
                <Button
                    onPress={() => {
                        Modal.alert('Title','Some Content Text', 'none',[{
                            text:'Confirm',
                            onPress:() => console.log('Pressed'),
                            color: 'red',
                        }])
                    }}
                    type="primary"
                >
                    Alert
                </Button>
                <Button
                    onPress={() => {
                        Modal.toast('Toast', 'warning')
                    }}
                    type="primary"
                    style={{ marginTop: 20 }}
                >
                    Toast
                </Button>
                <Button
                    onPress={() => {
                        Modal.prompt('Title', '', 'default', (input) => console.log(input),
                            {
                                errorHint: (input) => {
                                    if (input.length < 6) return 'Too Short'
                                    return false
                                },
                            })
                    }}
                    type="primary"
                    style={{ marginTop: 20 }}
                >
                    Prompt
                </Button>
                <Button
                    onPress={() => {
                        Modal.showLoading()
                        setTimeout(() => Modal.hideLoading(), 2000)
                    }}
                    type="primary"
                    style={{ marginTop: 20 }}
                >
                    Loading
                </Button>
            </View>
        )
    }
}

Method

alert

static alert(title, content?, icon?, actions?, options?)
参数说明类型默认值
title标题string''
content内容string''
icon图标 enum('none','error','success','warning','custom')string'none'
actions操作按钮array[{text:'确定'}]
options可选设置objectnull

action

key说明类型默认值
text文字string''
onPress点击事件funcnull
color文字颜色stringnull

option

key说明类型默认值
closeable可否点击遮罩关闭booleantrue
onDialogDismiss关闭事件funcnull
buttonDirection按钮排列方向 enum('auto','row','column')string'auto'
alertType弹窗类型 enum('default','close','never')string'default'
customIcon自定义icon资源anynull
iconStyleicon的Styleobjectnull
neverText不再提示的文字string'不再提示'
defaultNeverState默认不再提示勾选状态booleanfalse
neverKey不再提示本地存储的key值, alertType为'never'时必填string''

toast

static toast(text, icon?, duration?)
参数说明类型默认值
text内容string''
icon图标 enum('none','error','warning','success')string'none'
duration持续时间number1500

prompt

static prompt(title, content?, defaultValue?, onConfirm?, options?)
参数说明类型默认值
title标题string''
content内容string''
defaultValue默认输入值string''
onConfirm确定的回调funcnull
options可选设置objectnull

option

key说明类型默认值
negativeText取消文字string'取消'
positiveText确定文字string'确定'
invalidCondition确定按钮不可点击的条件func(result) => result.length === 0
maxLength最大长度number50
placeholder提示文字string''
errorHint格式校验错误文字, ''或false表示校验通过funcnull

showLoading

static showLoading(title?)
参数说明类型默认值
title标题string''

hideLoading

static hideLoading()

notice

static notice(title, content?, icon?, onPress?, onDismiss?, action?)
参数说明类型默认值
title标题string''
content内容string''
icon图标anynull
onPress点击事件funcnull
onDismiss删除设置funcnull
action点击位置的文字string'查看'
← DatePickerAvatar →
  • Basic Example:
  • Method
    • alert
    • toast
    • prompt
    • showLoading
    • hideLoading
    • notice
mCloud Design Mobile
Docs
Getting Started (or other categories)Guides (or other categories)API Reference (or other categories)
Community
User ShowcaseStack OverflowProject ChatTwitter
More
BlogGitHubStar
Facebook Open Source
Copyright © 2019 Your Name or Your Company Name