方案一
通过监听浏览器返回事件,转换为跳转到指定页面的方法
import { history } from 'umi';import { useEffect } from 'react';const back = () => {// 跳转到指定页面history.push = 'xxxx'}useEffect(() => {window.addEventListener('popstate', back, false);return () => {window.removeEventListener('popstate', back, false);};}, []);
方案二
暂未成功,研究中
window.history.pushState({ needClose: 1 }, '', '/audit?needClose=1');window.history.pushState('', '', '');
