Primitives

useLocation

编辑此页面

获取响应式的 location 对象,用于获取如 pathname 等信息

const location = useLocation();
const pathname = createMemo(() => parsePath(location.pathname));
属性类型描述
pathnamestringURL 的路径部分,不包含查询字符串
searchstringURL 的查询字符串部分
hashstringURL 的哈希部分,包含 # 符号
stateanyuseNavigate 传递的自定义状态
querystring返回一个类似存储的对象,包含 URL 的所有查询参数
报告此页面问题