react-native组件(2)--(react-native

2017-08-09  本文已影响116人  吃肉666

react-native-root-toast -- 浮动提示(类似SVProgressHUD)
安装
npm install react-native-root-toast --save
简单封装

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */
'use strict'

import Toast from 'react-native-root-toast'
let JSToast={

}

JSToast.show=(message)=>{
    // Add a Toast on screen.
    let toast = Toast.show(message, {
        duration: Toast.durations.LONG,
        position: Toast.positions.CENTER, //显示位置还有BOTTOM,TOP
        shadow: true,
        animation: true,
        hideOnPress: true,
        delay: 0,
        onShow: () => {
            // calls on toast\`s appear animation start
        },
        onShown: () => {
            // calls on toast\`s appear animation end.
        },
        onHide: () => {
            // calls on toast\`s hide animation start.
        },
        onHidden: () => {
            // calls on toast\`s hide animation end.
        }
    });

// You can manually hide the Toast, or it will automatically disappear after a `duration` ms timeout.
    setTimeout(function () {
        Toast.hide(toast);
    }, 2000);
}
module.exports = JSToast;

使用

import Toast from '../Common/JSToast' //导入文件

//到该用的地方直接调用方法就行了
Toast.show('提示信息');

上一篇下一篇

猜你喜欢

热点阅读