I'm using bootstrap-vue
for a SPA and I am working on a page where we need to nest some content within b-tabs
.
By given a url with an anchor (eg: www.mydomain.com/page123#tab-3
) I would like to show the content under Tab 3
.
Question: How do I do it within bootstrap-vue? Is there a native function I can use for that? reference: (I couldn't find it in the docs: https://bootstrap-vue.js.org/docs/components/tabs/)
Here is my code:
<b-tabs>
<b-tab title="Tab 1" active>
Tab 1 content
</b-tab>
<b-tab title="Tab 2">
Tab 2 content
</b-tab>
<b-tab title="Tab 3">
Tab 3 content
</b-tab>
</b-tabs>
And this is the rendered html code:
<div class="tabs">
<div class="">
<ul role="tablist" tabindex="0" class="nav nav-tabs">
<li class="nav-item">
<a role="tab" tabindex="-1" href="#" class="nav-link active">Tab 1</a>
</li>
<li class="nav-item">
<a role="tab" tabindex="-1" href="#" class="nav-link">Tab 2</a>
</li>
<li class="nav-item">
<a role="tab" tabindex="-1" href="#" class="nav-link">Tab 3</a>
</li>
</ul>
</div>
<div class="tab-content">
<div class="tab-pane show fade active">
Tab 1 content
</div>
<div class="tab-pane fade" style="display: none;">
Tab 2 content
</div>
<div class="tab-pane fade" style="display: none;">
Tab 3 content
</div>
</div>
</div>
www.mydomain.com/page123#?3
and then you simply check the Query on the Mounted and set the tab with that number to active. – Badgyboootstrap
, orbootstrap-vue
, orvue
itself. – Adriano