Skip to content

useAppRoot

获取到根信息配置,做点什么。

返回值

名称类型说明
getRootRouteComputedRef<AppRootRoute>根路由配置信息
getRootPathComputedRef<string>根路由路径
getRootNameComputedRef<string>根路由名称
setRootRoute(route: Partial<AppRootRoute>) => void动态设置根路由,会自动合并默认配置

AppRootRoute

code
ts
interface AppRootRoute {
  name: string
  path: string
}

基础使用

ts
import { useAppRoot } from '@/hooks'

const { getRootRoute, getRootPath, getRootName, setRootRoute } = useAppRoot()

setRootRoute({
  name: 'demo',
})
setRootRoute({
  path: '/demo',
})
setRootRoute({
  name: 'your name',
  path: 'your path',
})

Released under the MIT License.