// ViewReviewPage.tsx import React, { useState, useEffect } from 'react'; import { useLocation } from 'umi'; // 或者 'react-router-dom' import ResultModal from './components/ResultModal'; import ViewModal from './components/ViewModal'; const ViewReviewPage: React.FC = () => { const [modalVisible, setModalVisible] = useState(false); // 控制弹窗 const [modalRecord, setModalRecord] = useState(null); // 解析url参数 ?id=xxx const location = useLocation(); useEffect(() => { // 获取id参数 const params = new URLSearchParams(location.search); const id = params.get('id'); if (id) { setModalRecord({ id }); // 只传id也可以,后面可以根据id扩展更多参数 setModalVisible(true); } }, [location.search]); return (
{/* 其他页面内容 */} setModalVisible(false)} /> setModalVisible(false)} />
); }; export default ViewReviewPage;