🌐 AI搜索 & 代理 主页
Skip to content

Commit 67166c3

Browse files
mariusatmorehouse
authored andcommitted
docs(tabs): document load tab content only when active (closes #4352) (#4353)
1 parent 38d2077 commit 67166c3

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/components/tabs/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,46 @@ need to accommodate your custom classes for this._
380380
<!-- b-tabs-with-classes.vue -->
381381
```
382382

383+
## Lazy loading tab content
384+
385+
Sometimes it's preferred to load components & data only when activating a tab, instead of loading
386+
all tabs (and associated data) when rendering the `<b-tabs>` set.
387+
388+
Individual `<b-tab>` components can be lazy loaded via the `lazy` prop, which when set doesn't mount
389+
the content of the `<b-tab>` until it is activated (shown), and will be un-mounted when the tab is
390+
deactivated (hidden):
391+
392+
```html
393+
<b-tabs>
394+
<b-tab title="abc">
395+
<!-- this content will always be mounted -->
396+
<div>Tab ABC content</div>
397+
</b-tab>
398+
<b-tab title="xyz" lazy>
399+
<!-- this content will not be mounted until this tab is shown -->
400+
<!-- and will be un-mounted when hidden -->
401+
<my-xyz-component></my-xyz-component>
402+
</b-tab>
403+
</b-tabs>
404+
```
405+
406+
One can also make all tab's lazy by setting the `lazy` prop on the parent `<b-tabs>` component:
407+
408+
```html
409+
<b-tabs lazy>
410+
<b-tab title="abc">
411+
<!-- this content will not be mounted until this tab is shown -->
412+
<!-- and will be un-mounted when hidden -->
413+
<div>Tab ABC content</div>
414+
</b-tab>
415+
<b-tab title="xyz">
416+
<!-- this content will not be mounted until this tab is shown -->
417+
<!-- and will be un-mounted when hidden -->
418+
<my-xyz-component></my-xyz-component>
419+
</b-tab>
420+
</b-tabs>
421+
```
422+
383423
## Keyboard navigation
384424

385425
Keyboard navigation is enabled by default for ARIA compliance with tablists when a tab button has

0 commit comments

Comments
 (0)