reactnative toast(ios 和android 通用)

来源:互联网 发布:ubuntu 14.10 samba 编辑:程序博客网 时间:2024/06/03 20:17

 想在 ios 和android 都用 Toast 

githob https://github.com/magicismight/react-native-root-toast.git


在这里可以自定义 toast   


这里 简单介绍 常规写法

import React, { Component } from 'react';import Toast from 'react-native-root-toast';class Example extends Component{    constructor() {        super(...arguments);        this.state = {            visible: false        };    }    componentDidMount() {        setTimeout(() => this.setState({            visible: true        }), 2000); // show toast after 2s        setTimeout(() => this.setState({            visible: false        }), 5000); // hide toast after 5s    };    render() {        return <Toast            visible={this.state.visible}            position={150}//据 顶端 的距离            shadow={false}            animation={true}             hideOnPress={true}//点击他出 后隐藏        >This is a message</Toast>;    }}module .exports = Example;

0 0