useMatches
返回頁面上目前的路由匹配。這對於使用您目前的路由建立佈局抽象很有用。
function SomeComponent() {
const matches = useMatches();
// ...
}
matches
具有以下形狀
[
{ id, pathname, data, params, handle }, // root route
{ id, pathname, data, params, handle }, // layout route
{ id, pathname, data, params, handle }, // child route
// etc.
];