想在 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;