• 一款基于react-native的弹窗提示组件


    介绍一款基于react-native的弹窗提示插件 react-native-ms ,

    github地址:https://github.com/jiangzhenfei/react-native-ms

    样式图

    该组件还支持自己定义的icon组件

    主要的使用法法如下

    npm下载组件

    npm install react-native-ms --save

    在页面中使用

    import { TipModal } from 'react-native-ms';
    import React, {Component} from 'react';
    import {Platform, StyleSheet, Text, View,Button} from 'react-native';
    
    export default class App extends Component {
      /* 打开loading弹出框 */
      loading(){
        this.refs.tipModal._loading()
      }
      /* 打开成功提示框,参数一是提示内容,参数二是多少时间自动关闭*/
      _success(){
        this.refs.tipModal._success('成功了',500)
      }
      /* 打开失败提示框,参数一是提示内容,参数二是多少时间自动关闭*/
      _error(){
        this.refs.tipModal._error('失败了',500)
      }
      render() {
        return (
          <View style={styles.container}>
            <TipModal ref="tipModal"/>
            <Button title="loading" onPress={this.loading.bind(this)}/>
            <Button title="_success" onPress={this._success.bind(this)}/>
            <Button title="_error" onPress={this._error.bind(this)}/>
          </View>
            );
        } } 

    修改自定义icon属性,成功提示框自定义icon

    <TipModal ref="tipModal"
      successIconComponent={
        <Icon 
          color = '#FFFFFF'
          type = 'evilicon'
          name = 'check'
          size = { 30 }
        />
      }
    />

    失败提示框自定义icon组件

    <TipModal ref="tipModal"
      errorIconComponent={
        <Icon 
          color = '#FFFFFF'
          type = 'evilicon'
          name = 'close-o'
          size = { 30 }
        />
      }
    />

     接下来是确认弹窗提示的组件效果

    import {Platform, StyleSheet, Text, View,Button} from 'react-native';
    import { ConfirmModal } from 'react-native-ms'
    
    
    export default class App extends Component {
      confirm(){
        this.refs.tipModal2._open('默认的提示')
      }
      render() {
        return (
          <View style={styles.container}>		
            <ConfirmModal ref="tipModal2"
              confirmFunc={()=>{alert(1)}}
            />         <Button title="confirm" onPress={this.confirm.bind(this)}/>       </View>     );
      } }

     

  • 相关阅读:
    Influxdb修改数据保留策略
    PPT插件(islide)
    有关 MyEclipse->export runnable jar file选项 launch configuration里面没有可以选择的东西的解决方法
    使用SoapUI发送Post请求
    JSONObject 转换 JSON复杂对象
    SQL按照指定顺序对字段进行排序
    全面盘点当前Android后台保活方案的真实运行效果(截止2019年前)
    如何去maven仓库下载jar包
    maven学习(下)利用Profile构建不同环境的部署包
    maven学习(中)- 私服nexus搭建
  • 原文地址:https://www.cnblogs.com/zhenfei-jiang/p/9454352.html
Copyright © 2020-2023  润新知