UNPKG

t-comm

Version:

专业、稳定、纯粹的工具库

38 lines (35 loc) 953 B
import _typeof from '@babel/runtime/helpers/typeof'; import { a as __rest } from '../tslib.es6-848120af.js'; /** * 根据路由跳转时的参数,提取 path 和其他参数 * @param route $router.push 或者 $router.replace 的参数 * @returns 解析结果 * @example * ```ts * getRouterFuncPath('/foo/bar'); * // { path: '/foo/bar', other: {} } * * getRouterFuncPath({ path: '/foo/bar', query: { a: 1 } }); * // { path: '/foo/bar', other: { query: { a: 1 } } } * * getRouterFuncPath({ name: 'home' }); * // { path: undefined, other: {} } * ``` */ function getRouterFuncPath(route) { var rawPath; var rawOther = {}; if (_typeof(route) === 'object' && route.path) { rawPath = route.path; route.path; var other = __rest(route, ["path"]); rawOther = other; } else if (typeof route === 'string') { rawPath = route; } return { path: rawPath, other: rawOther }; } export { getRouterFuncPath };