Skip to content

属性 ​

属性名说明类型默认值
defaultTabs默认页签ITabData 数组[]
homeTab固定首页:始终第一位、不可关闭、不可拖动;其他页签不能排到它前面;不配置时保持原行为ITabData—
max最大打开数量number20
contextmenu右键菜单。true(默认)= 内置菜单;false = 浏览器默认菜单;IContextMenu[] = 追加自定义菜单项boolean | IContextMenu[]true
pageTransition前进时的页面转场效果stringstack-tab-swap
pageTransitionBack后退时的页面转场效果stringstack-tab-swap-back
tabTransition标签转场效果,可传字符串或 TransitionProps 对象string | TransitionPropsstack-tab-zoom
tabScrollMode页签滚动模式TabScrollModeTabScrollMode.BOTH
space页签滚动一步的像素距离number300
width组件宽度string100%
height组件高度string100%
i18n当前语言,内置 zh-CN / enstringzh-CN
globalScroll全局滚动booleanfalse
scrollContainer自定义滚动组件,渲染在每个缓存页内部;需渲染默认插槽并 expose scrollElement(或实现 StackTabsScrollAdapter)Component—
iframePathiframe 占位路由路径(必填)string—
iframeAllowedOrigins允许 postMessage 调用 openTab 的 iframe 来源,会与当前 origin 合并string[][]
iframeSandboxiframe sandbox 策略;默认兼容优先不是强隔离,强隔离请移除 allow-same-origin;传空字符串关闭 sandbox(不推荐)stringallow-scripts allow-forms allow-popups allow-downloads allow-same-origin
iframeReferrerPolicyiframe referrerpolicy 属性ReferrerPolicystrict-origin-when-cross-origin
iframeAllowiframe allow 属性(Permissions Policy),例如 fullscreenstring''
iframeLoadTimeoutiframe 加载超时时间(ms),超时后展示错误 UInumber15000
sessionPrefixsessionStorage 键前缀;同一 origin 下托管多实例时用于隔离string''

注意:iframePath 必填,缺失时开发环境会抛 Error,生产环境会打印 console.error。详见 Nuxt 集成 与 iframe 与父窗口通信。

事件 ​

事件参数说明
onActiveid: string页签被激活时触发,点击页签或通过 API 激活都会触发
onPageLoaded—页签内页面挂载完成、或从 keep-alive 缓存重新激活时触发
vue
<template>
  <vue-stack-tabs
    iframe-path="/iframe"
    @on-active="(id) => console.log('当前页签:', id)"
    @on-page-loaded="() => console.log('页面就绪')"
  />
</template>

onPageLoaded 在缓存页每次激活时都会触发,不只是首次挂载。

Released under the Apache License.