美文网首页
react-native组件(2)--(react-native

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

作者: 吃肉666 | 来源:发表于2017-08-09 11:01 被阅读116次

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('提示信息');

相关文章

网友评论

      本文标题:react-native组件(2)--(react-native

      本文链接:https://www.haomeiwen.com/subject/gmufrxtx.html