import React from 'react'; import { Toast } from './toast'; import { Cell } from '../cell/cell'; import { DemoCard, DemoPage } from '../configprovider/styles/demo.page'; const ToastDemo = () => { const textToast = (msg) => { Toast.text(msg); }; const titleToast = (msg) => { Toast.text(msg, { title: '标题提示' }); }; const successToast = (msg) => { Toast.success(msg); }; const errorToast = (msg) => { Toast.fail(msg); }; const warningToast = (msg) => { Toast.warn(msg); }; const loadingToast = (msg) => { Toast.loading(msg); }; const duringToast = (msg) => { Toast.text(msg, { duration: 10000 }); }; const toastBottom = (msg) => { Toast.text(msg, { center: false, bottom: '10%', }); }; const iconToast = (msg) => { Toast.loading(msg, { cover: true, // 是否展示透明遮罩层 coverColor: 'rgba(0, 0, 0, 0)', // 遮罩颜色设定 closeOnClickOverlay: true, // 点击遮罩可关闭 onClose: () => { console.log('closeToast'); }, }); }; return ( textToast('网络失败,请稍后再试~')} /> titleToast('标题提示')} /> successToast('成功提示')} /> errorToast('失败提示')} /> warningToast('警告提示')} /> loadingToast('加载中')} /> duringToast('设置展示时长为10秒')} /> { Toast.text('Toast 不消失', { duration: 0 }); setTimeout(() => { Toast.hide(); }, 10000); }} /> toastBottom('自定义距离')} /> iconToast('Loading状态透明遮罩')} /> ); }; export default ToastDemo;