阅读时间:1 分钟
0 字

标签页方法 (useTabStore)

标签页状态由 useTabStore 提供。

使用方法

ts
import { useTabStore } from '@duxweb/dvha-core'

const tabStore = useTabStore()

返回值

字段类型说明
currentRef<string | undefined>当前标签路径
tabsRef<IMenu[]>标签列表
isTab(path: string) => boolean是否已存在
addTab(item: IMenu, cb?: (item: IMenu) => void) => void添加标签
delTab(path: string, cb?: (item: IMenu) => void) => void删除标签
changeTab(path: string, cb?: (item: IMenu) => void) => void切换标签
delOther(path: string, cb?: () => void) => void关闭其他
delLeft(path: string, cb?: () => void) => void关闭左侧
delRight(path: string, cb?: () => void) => void关闭右侧
lockTab(path: string) => void锁定/解锁
clearTab() => void清空全部

示例

ts
import { useRouter } from 'vue-router'
import { useTabStore } from '@duxweb/dvha-core'

const router = useRouter()
const tab = useTabStore()

tab.addTab({ name: 'users', label: '用户', path: '/admin/users' }, (item) => {
  router.push(item.path || '')
})