一、下载
npm i react-native-easy-toast
二、使用
注:请务必将 Toast
添加到根视图的底部。
import Toast from 'react-native-easy-toast';
export default function Register() {
const toastRef = useRef();
const login=()=>{
toastRef.current.show('incomplete information');
//显示时间
toastRef.current.show(
'The password must be a combination of letters and numbers',2000
);
}
return(
<Toast ref={toastRef} />
)
}
一般toast位置是在下面,如需调整
<Toast ref={toastRef} position='center'/>
(['top','center','bottom',])
官网(https://www.npmjs.com/package/react-native-easy-toast)