64 lines
1.3 KiB
Vue
Raw Normal View History

2021-03-25 22:33:41 +08:00
<template>
<div class="container">
<nav>
<div class="nav nav-tabs" :id="tag" role="tablist">
<button
v-for="tab of children"
class="nav-link"
:id="tab.labelID"
data-bs-toggle="tab"
:data-bs-target="'#' + tab.tabID"
type="button"
role="tab"
:aria-controls="tab.tabID"
aria-selected="false"
>
{{ tab.title }}
</button>
</div>
</nav>
2021-03-26 10:15:33 +08:00
<div :id="contentTag" class="tab-content">
2021-03-25 22:33:41 +08:00
<slot />
</div>
</div>
</template>
<script lang="ts">
import Vue from "vue";
export default Vue.extend({
props: {
title: {
type: String
}
},
data() {
return {
children: []
};
},
created() {
this.children = this.$children;
},
mounted() {
this.$nextTick(function() {
2021-03-25 23:30:08 +08:00
const bootstrap = require("bootstrap");
2021-03-25 22:33:41 +08:00
let triggerEl = document.getElementById(this.children["0"].$data.labelID);
2021-03-25 23:30:08 +08:00
new bootstrap.Tab(triggerEl).show();
2021-03-25 22:33:41 +08:00
});
},
computed: {
tag: function() {
return "tabs-" + this.title;
2021-03-26 10:15:33 +08:00
},
contentTag: function() {
return "tabs-" + this.title + "-content";
2021-03-25 22:33:41 +08:00
}
}
});
</script>
<style lang="scss" scoped>
@import "~bootstrap/scss/bootstrap";
</style>