import {useParams,useSearchParams,useLocation,useNavigate} from 'react-router-dom';
import './Detail.css'
function Detail() {
    let {productId} = useParams();
    let [searchParams] = useSearchParams();
    let {state} = useLocation();
    let go = useNavigate();
    function handleBack() {
        // 编程式导航
        go(-1);
    }
    return (
        <>
            <h1>详情</h1>
            <p>当前浏览商品的ID是:{productId || searchParams.get('productId') || state.productId}</p>
            <button className='btn' onClick={handleBack}>返回上级</button>
        </>
    )
}
export default Detail;