/** * @author lvzhiyi * * @description Toast提示插件 */ import React from 'react'; import ReactDOM from 'react-dom'; import './style.styl'; function MyContainer({ msg }: any) { return (
{msg}
); } const Toast = (msg: any, timer = 3000) => { const doc = window.document; const node = doc.createElement('div'); doc.body.appendChild(node); ReactDOM.render(, node, () => { const toastNode = node.getElementsByTagName('div')[0]; toastNode.style.animation = `toastAnimate ${timer + 500}ms`; setTimeout(() => { window.document.body.removeChild(node); }, timer); }); return; }; export default Toast;